Skip to content

Commit ee4f816

Browse files
fix: fall back to direct merge when branch protection has no required checks
1 parent eb5fc8c commit ee4f816

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

.github/workflows/dependabot-major-merge.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,18 @@ jobs:
106106
fi
107107
108108
echo "✅ CI passed for PR #$PR_NUMBER — enabling auto-merge..."
109-
gh pr merge --auto --squash "$PR_URL"
110-
echo "✅ Auto-merge enabled for PR #$PR_NUMBER."
109+
MERGE_OUTPUT=$(gh pr merge --auto --squash "$PR_URL" 2>&1) && \
110+
echo "✅ Auto-merge enabled for PR #$PR_NUMBER." || \
111+
{
112+
if echo "$MERGE_OUTPUT" | grep -q "clean status"; then
113+
echo "Branch protection has no required checks — merging directly..."
114+
gh pr merge --squash --delete-branch "$PR_URL"
115+
echo "✅ PR #$PR_NUMBER merged directly."
116+
else
117+
echo "::error::Failed to merge PR #$PR_NUMBER: $MERGE_OUTPUT"
118+
exit 1
119+
fi
120+
}
111121
done
112122
113123
# ── pull_request / workflow_dispatch: single PR ─────────────────
@@ -193,7 +203,19 @@ jobs:
193203
# ── 4. Enable auto-merge ───────────────────────────────────────
194204
- name: Enable auto-merge
195205
if: github.event_name != 'workflow_run'
196-
run: gh pr merge --auto --squash "$PR_URL"
197206
env:
198207
PR_URL: ${{ steps.resolve.outputs.pr_url }}
199208
GH_TOKEN: ${{ secrets.GH_PAT_WORKFLOW }}
209+
run: |
210+
MERGE_OUTPUT=$(gh pr merge --auto --squash "$PR_URL" 2>&1) && \
211+
echo "✅ Auto-merge enabled." || \
212+
{
213+
if echo "$MERGE_OUTPUT" | grep -q "clean status"; then
214+
echo "Branch protection has no required checks — merging directly..."
215+
gh pr merge --squash --delete-branch "$PR_URL"
216+
echo "✅ PR merged directly."
217+
else
218+
echo "::error::Failed to merge PR: $MERGE_OUTPUT"
219+
exit 1
220+
fi
221+
}

0 commit comments

Comments
 (0)