fix(ci): serialize auto-merge enable and ignore already-enabled

This commit is contained in:
Adam Moussa 2026-08-21 19:16:25 -04:00
parent 6b1c2a3795
commit e0b80c55e8
No known key found for this signature in database

View file

@ -5,6 +5,10 @@ on:
types: [opened, ready_for_review, reopened, synchronize]
branches: [main]
concurrency:
group: enable-auto-merge-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
@ -29,4 +33,12 @@ jobs:
echo "auto-merge already enabled"
exit 0
fi
gh pr merge "$PR" --repo "$REPO" --auto
if ! out=$(gh pr merge "$PR" --repo "$REPO" --auto 2>&1); then
echo "$out"
if [ "$(gh pr view "$PR" --repo "$REPO" --json autoMergeRequest --jq '.autoMergeRequest != null')" = "true" ]; then
echo "auto-merge already enabled"
exit 0
fi
exit 1
fi
printf '%s\n' "$out"