44 workflow_run :
55 workflows : [Create Release]
66 types : [requested]
7- branches : [main, develop]
7+ branches : [main]
88 workflow_dispatch :
99 pull_request :
1010 types : [opened, edited, synchronize, reopened]
11- branches : [main, develop ]
11+ branches : [main]
1212
1313permissions :
1414 contents : read
@@ -24,19 +24,22 @@ jobs:
2424 - id : set_branch
2525 shell : bash
2626 run : |
27- # 1. Pick the raw branch/ref for each trigger type
27+ # Pick the ref to test for each trigger type.
28+ # For pull_request, test the PR head SHA (the incoming changes),
29+ # not the base branch. Using the SHA is deterministic even if
30+ # the PR branch is later force-pushed.
2831 if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
29- RAW='${{ github.event.workflow_run.head_branch }}'
32+ RAW='${{ github.event.workflow_run.head_sha }}'
3033 elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
31- RAW='${{ github.event.pull_request.base.ref }}'
32- else
33- RAW='${{ github.ref }}'
34+ RAW='${{ github.event.pull_request.head.sha }}'
35+ else
36+ RAW='${{ github.ref }}'
3437 fi
3538
36- # 2. Strip the refs/heads/ prefix if present
39+ # Strip the refs/heads/ prefix if present (only relevant for the push/dispatch fallback)
3740 CLEAN="${RAW#refs/heads/}"
3841
39- echo "Detected branch : $CLEAN"
42+ echo "Detected ref : $CLEAN"
4043 echo "branch_name=$CLEAN" >> "$GITHUB_OUTPUT"
4144
4245 test :
0 commit comments