From e776ea7fe252c530dce682ba99a2698eb1a968ca Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar Date: Wed, 18 Feb 2026 10:05:37 +0100 Subject: [PATCH] fix(ci): use SHA-based fetch for checkout GITHUB_REF_NAME resolves to the PR number on pull_request events, not the branch name. Fetch by commit SHA directly which works for both push and pull_request triggers. Co-Authored-By: Claude Opus 4.6 --- .gitea/workflows/ci.yml | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 8226543..9d40511 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -29,8 +29,10 @@ jobs: steps: - name: Checkout run: | - git clone --depth=1 --branch="${GITHUB_REF_NAME}" "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" . - git checkout "${GITHUB_SHA}" + git init + git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + git fetch --depth=1 origin "${GITHUB_SHA}" + git checkout FETCH_HEAD - run: rustup component add rustfmt - run: cargo fmt --check @@ -42,8 +44,10 @@ jobs: steps: - name: Checkout run: | - git clone --depth=1 --branch="${GITHUB_REF_NAME}" "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" . - git checkout "${GITHUB_SHA}" + git init + git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + git fetch --depth=1 origin "${GITHUB_SHA}" + git checkout FETCH_HEAD - run: rustup component add clippy # Lint both feature sets independently - name: Clippy (server) @@ -59,8 +63,10 @@ jobs: steps: - name: Checkout run: | - git clone --depth=1 --branch="${GITHUB_REF_NAME}" "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" . - git checkout "${GITHUB_SHA}" + git init + git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + git fetch --depth=1 origin "${GITHUB_SHA}" + git checkout FETCH_HEAD - run: cargo install cargo-audit - run: cargo audit @@ -76,8 +82,10 @@ jobs: steps: - name: Checkout run: | - git clone --depth=1 --branch="${GITHUB_REF_NAME}" "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" . - git checkout "${GITHUB_SHA}" + git init + git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + git fetch --depth=1 origin "${GITHUB_SHA}" + git checkout FETCH_HEAD - name: Run tests (server) run: cargo test --features server --no-default-features - name: Run tests (web) @@ -97,8 +105,10 @@ jobs: steps: - name: Checkout run: | - git clone --depth=1 --branch="${GITHUB_REF_NAME}" "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" . - git checkout "${GITHUB_SHA}" + git init + git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + git fetch --depth=1 origin "${GITHUB_SHA}" + git checkout FETCH_HEAD - name: Determine image tag id: tag