Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,18 @@ jobs:
GH_TOKEN: ${{ steps.app.outputs.token }}
PR: ${{ github.event.pull_request.number }}
HEAD: ${{ github.event.pull_request.head.sha }}
run: gh pr merge "$PR" -R "$GITHUB_REPOSITORY" --squash --delete-branch --match-head-commit "$HEAD"
run: |
# A merge right after another can meet "base branch policy prohibits the merge"
# while GitHub catches up: try again up to 3 times, 20 seconds apart. Any
# other refusal (the head moved, a check failed) fails at once.
for try in 1 2 3 4; do
if out="$(gh pr merge "$PR" -R "$GITHUB_REPOSITORY" --squash --delete-branch --match-head-commit "$HEAD" 2>&1)"; then
echo "$out"; exit 0
fi
echo "$out" >&2
grep -qi "base branch policy prohibits the merge" <<< "$out" || exit 1
[ "$try" -lt 4 ] || break
echo "The base branch policy refused the merge (try $try of 4); trying again in 20 seconds."
sleep 20
done
exit 1