Skip to content

Commit 32c2546

Browse files
fix: do not automatically merge release PRs if they are already closed (Mellanox#1542)
2 parents be38693 + 82cfb49 commit 32c2546

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

.github/workflows/release-pr-checker.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ jobs:
7777
- uses: actions/checkout@v4
7878
with:
7979
sparse-checkout: .
80-
- run:
81-
# There are branch protection rules in place, to override them, we need to pass --admin option
82-
gh pr merge $PR_NUMBER --merge --delete-branch --admin
80+
- run: |
81+
# Check if PR is open before attempting to merge
82+
PR_STATE=$(gh pr view $PR_NUMBER --json state -q .state)
83+
if [ "$PR_STATE" = "OPEN" ]; then
84+
# There are branch protection rules in place, to override them, we need to pass --admin option
85+
gh pr merge $PR_NUMBER --merge --delete-branch --admin
86+
else
87+
echo "PR #$PR_NUMBER is not open (current state: $PR_STATE). Skipping merge."
88+
exit 1
89+
fi

0 commit comments

Comments
 (0)