Skip to content

Commit 62057bd

Browse files
heiskrCopilot
andauthored
delete-orphan-translation-files: fall back to direct merge if auto-merge unavailable (#60899)
Co-authored-by: Kevin Heis <1221423+heiskr@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 39ab87a commit 62057bd

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

.github/workflows/delete-orphan-translation-files.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,28 @@ jobs:
133133
--label "workflow-generated" \
134134
--head=$branch_name
135135
echo "Merge created PR..."
136-
retry_command gh pr merge --merge --auto --delete-branch "$branch_name"
136+
# Prefer enabling auto-merge so the PR waits for any required
137+
# checks before merging. If auto-merge can't be enabled — usually
138+
# because all required checks completed before this step ran and
139+
# the PR is already immediately mergeable — fall back to a direct
140+
# merge. GitHub returns one of these misleading errors in that
141+
# case: "Branch does not have required protected branch rules",
142+
# "Pull request is in unstable status", or "Pull request is not
143+
# in a mergeable state".
144+
auto_merge_err=$(mktemp)
145+
trap 'rm -f "$auto_merge_err"' EXIT
146+
if retry_command gh pr merge --merge --auto --delete-branch "$branch_name" 2>"$auto_merge_err"; then
147+
:
148+
else
149+
cat "$auto_merge_err"
150+
if grep -qE "does not have required protected branch rules|unstable status|Pull request is not in a mergeable state" "$auto_merge_err"; then
151+
echo "Auto-merge unavailable; PR appears immediately mergeable. Falling back to direct merge."
152+
retry_command gh pr merge --merge --delete-branch "$branch_name"
153+
else
154+
echo "Auto-merge failed with an unexpected error."
155+
exit 1
156+
fi
157+
fi
137158
138159
- uses: ./.github/actions/slack-alert
139160
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}

0 commit comments

Comments
 (0)