fix(autoupdate): retry the PR merge on a transient GitHub error

This commit is contained in:
2026-10-03 22:58:15 +01:00
parent 26ad486b78
commit b23191de71
+15 -5
View File
@@ -561,11 +561,21 @@ jobs:
exit 0
fi
# --match-head-commit refuses to merge anything newer than the commit that was tested.
if ! gh pr merge "$pr" --repo "$GITHUB_REPOSITORY" --squash --delete-branch \
--match-head-commit "$HEAD_SHA" \
--subject "$SUBJECT" \
--body "Automated dependency update. All tests passed." \
${ADMIN:+--admin}; then
# GitHub answers 5xx now and then; a failed call may still have merged, so check the state before retrying.
merged=false
for _ in 1 2 3; do
if gh pr merge "$pr" --repo "$GITHUB_REPOSITORY" --squash --delete-branch \
--match-head-commit "$HEAD_SHA" \
--subject "$SUBJECT" \
--body "Automated dependency update. All tests passed." \
${ADMIN:+--admin}; then
merged=true
break
fi
sleep 10
[ "$(gh pr view "$pr" --repo "$GITHUB_REPOSITORY" --json state --jq .state)" = MERGED ] && { merged=true; break; }
done
if [ "$merged" != true ]; then
gh pr close "$pr" --repo "$GITHUB_REPOSITORY" --comment "The tests passed, but GitHub refused the merge. See the workflow run. The next run tries again."
exit 1
fi