Fix checkout to use head_ref for PRs
All checks were successful
Test CI / test (pull_request) Successful in 0s

gitea.ref_name returns PR number for pull_request events, need to
use gitea.head_ref to get the actual branch name.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Erich Blume 2026-01-23 16:56:18 -08:00
commit 66c20e8edd

View file

@ -12,7 +12,9 @@ jobs:
steps:
- name: Checkout (git clone)
run: |
git clone --depth 1 --branch "${{ gitea.ref_name }}" \
# For PRs use head_ref (branch name), for pushes use ref_name
BRANCH="${{ gitea.head_ref || gitea.ref_name }}"
git clone --depth 1 --branch "$BRANCH" \
"${{ gitea.server_url }}/${{ gitea.repository }}.git" .
env:
GIT_SSL_NO_VERIFY: "true"
@ -22,5 +24,6 @@ jobs:
echo "Hello from Forgejo Actions!"
echo "Runner: $(hostname)"
echo "Repository: ${{ gitea.repository }}"
echo "Branch: ${{ gitea.ref_name }}"
echo "Event: ${{ gitea.event_name }}"
echo "Ref: ${{ gitea.ref }}"
ls -la