From 161256a7be0e098ee2ef78a12f17fd001b86b33e Mon Sep 17 00:00:00 2001 From: Cristiano Betta Date: Fri, 4 Dec 2026 12:29:20 +0000 Subject: [PATCH 1/2] ci: the merge job retries a base-branch-policy refusal up to 3 times Spec agents-autonomy, A8. Only that refusal is retried, 20 seconds apart; any other fails at once, and --match-head-commit is unchanged. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e13c14..c6c022e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -133,4 +133,18 @@ jobs: GH_TOKEN: ${{ steps.app.outputs.token }} PR: ${{ github.event.pull_request.number }} HEAD: ${{ github.event.pull_request.head.sha }} - run: gh pr merge "$PR" -R "$GITHUB_REPOSITORY" --squash --delete-branch --match-head-commit "$HEAD" + run: | + # A merge right after another can meet "base branch policy prohibits the merge" + # while GitHub catches up: try again up to 3 times, 20 seconds apart. Any + # other refusal (the head moved, a check failed) fails at once. + for try in 1 2 3 4; do + if out="$(gh pr merge "$PR" -R "$GITHUB_REPOSITORY" --squash --delete-branch --match-head-commit "$HEAD" 2>&1)"; then + echo "$out"; exit 0 + fi + echo "$out" >&2 + case "$out" in *"base branch policy prohibits the merge"*) ;; *) exit 1 ;; esac + [ "$try" -lt 4 ] || break + echo "The base branch policy refused the merge (try $try of 4); trying again in 20 seconds." + sleep 20 + done + exit 1 From fe039faf3b0aefbf295fb2990c09ec78da3bcd9f Mon Sep 17 00:00:00 2001 From: Cristiano Betta Date: Fri, 4 Dec 2026 13:29:20 +0000 Subject: [PATCH 2/2] ci: match the policy refusal case-insensitively GitHub can send it as "Base branch policy prohibits the merge" with a capital B (Copilot, betta-design#56 and hackcoc#53). Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6c022e..a5da9e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -142,7 +142,7 @@ jobs: echo "$out"; exit 0 fi echo "$out" >&2 - case "$out" in *"base branch policy prohibits the merge"*) ;; *) exit 1 ;; esac + grep -qi "base branch policy prohibits the merge" <<< "$out" || exit 1 [ "$try" -lt 4 ] || break echo "The base branch policy refused the merge (try $try of 4); trying again in 20 seconds." sleep 20