File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -13,15 +13,31 @@ jobs:
1313 contents : read
1414 env :
1515 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
16- SOURCE_BRANCH : " ${{ github.event.client_payload.SOURCE_BRANCH }}"
16+ SOURCE_BRANCH : " ${{ github.event.client_payload.TRIGGERING_PAYLOAD. SOURCE_BRANCH }}"
1717
1818 steps :
19+ - name : Validate source branch
20+ run : |
21+ if [[ -z "$SOURCE_BRANCH" ]]; then
22+ echo "SOURCE_BRANCH is empty or missing – aborting"
23+ exit 1
24+ fi
1925 - name : Skip protected branches
2026 id : check_branch
2127 run : |
2228 if [[ "$SOURCE_BRANCH" == "main" || "$SOURCE_BRANCH" == "release/"* ]]; then
2329 echo "Protected branch $SOURCE_BRANCH – skipping"
2430 echo "skip=true" >> $GITHUB_OUTPUT
31+ else
32+ echo "skip=false" >> $GITHUB_OUTPUT
33+ fi
34+
35+ - name : Check if PR exists
36+ if : steps.check_branch.outputs.skip != 'true'
37+ run : |
38+ if ! gh pr view "$SOURCE_BRANCH" --repo ${{ github.repository }} >/dev/null 2>&1; then
39+ echo "No open PR found for branch $SOURCE_BRANCH – nothing to close"
40+ exit 0
2541 fi
2642
2743 - name : Close PR
You can’t perform that action at this time.
0 commit comments