Skip to content

Commit 5312a5d

Browse files
Lykhoydaclaude
andauthored
ci(release): direct-merge fallback only when the Version PR is already clean (#291)
The "enable auto-merge" step failed intermittently with "GraphQL: Pull request is in clean status (enablePullRequestAutoMerge)". Root cause: the changeset-release/main branch has no required status checks, so the Version Packages PR is frequently immediately mergeable — and `gh pr merge --auto` errors when there's no pending gate to attach to (most recently on the #214 release, also seen earlier on bc577e9). Fix: try --auto; on failure, direct-merge ONLY when the error is the benign "Pull request is in clean status". Any other auto-merge failure (e.g. "Allow auto-merge" disabled, missing permission) fails the job loudly instead of silently direct-merging — addressing a review finding that a blanket `|| direct-merge` would mask repo-settings drift. A failing/pending check never reaches the fallback: --auto succeeds at *enabling* in that case and just waits, so this cannot bypass a real check. CI-only change; require-changeset excludes .github/, so no changeset. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 76c87ba commit 5312a5d

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,31 @@ jobs:
5151
env:
5252
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5353

54-
- name: Enable auto-merge on the Version Packages PR
54+
# Prefer auto-merge (it gates on any pending checks). `gh pr merge --auto`
55+
# ERRORS only when auto-merge can't be enabled — most commonly because the
56+
# PR is already in a clean/mergeable state: the changeset-release/main
57+
# branch has no required status checks, so the Version PR is usually
58+
# immediately mergeable and there is no gate to attach to. Fall back to a
59+
# direct merge ONLY for that specific benign error. Any OTHER auto-merge
60+
# failure (e.g. "Allow auto-merge" disabled, missing permission) must fail
61+
# the job loudly rather than silently direct-merging — a failing/pending
62+
# check never lands here, because --auto succeeds at *enabling* in that
63+
# case and simply waits.
64+
- name: Merge the Version Packages PR (auto-merge, or direct only if already clean)
5565
if: steps.changesets.outputs.pullRequestNumber
5666
env:
5767
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5868
PR_NUMBER: ${{ steps.changesets.outputs.pullRequestNumber }}
59-
run: gh pr merge --squash --auto "$PR_NUMBER"
69+
run: |
70+
if out=$(gh pr merge --squash --auto "$PR_NUMBER" 2>&1); then
71+
echo "$out"
72+
else
73+
echo "$out"
74+
if printf '%s' "$out" | grep -q "Pull request is in clean status"; then
75+
echo "auto-merge not applicable (PR already mergeable) — merging directly"
76+
gh pr merge --squash "$PR_NUMBER"
77+
else
78+
echo "auto-merge failed for an unexpected reason — not falling back" >&2
79+
exit 1
80+
fi
81+
fi

0 commit comments

Comments
 (0)