From a646f23cfb914e43e77f976ee3617b1c29c05918 Mon Sep 17 00:00:00 2001 From: Adam Moussa Date: Fri, 21 Aug 2026 18:58:07 -0400 Subject: [PATCH 1/5] fix(ci): restore contents write and re-run auto-merge on push --- .github/workflows/auto-merge.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-merge.yaml b/.github/workflows/auto-merge.yaml index aa8fdcc..a42db32 100644 --- a/.github/workflows/auto-merge.yaml +++ b/.github/workflows/auto-merge.yaml @@ -2,10 +2,11 @@ name: Enable auto-merge on: pull_request: - types: [opened, ready_for_review, reopened] + types: [opened, ready_for_review, reopened, synchronize] branches: [main] permissions: + contents: write pull-requests: write jobs: From 5f65d3405edf807cf8a0e6d6dea66b82df493934 Mon Sep 17 00:00:00 2001 From: Adam Moussa Date: Fri, 21 Aug 2026 19:14:26 -0400 Subject: [PATCH 2/5] fix(ci): serialize auto-merge enable and ignore already-enabled --- .github/workflows/auto-merge.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-merge.yaml b/.github/workflows/auto-merge.yaml index a42db32..f0ef235 100644 --- a/.github/workflows/auto-merge.yaml +++ b/.github/workflows/auto-merge.yaml @@ -5,6 +5,10 @@ on: types: [opened, ready_for_review, reopened, synchronize] branches: [main] +concurrency: + group: enable-auto-merge-${{ github.event.pull_request.number }} + cancel-in-progress: true + permissions: contents: write pull-requests: write @@ -29,4 +33,12 @@ jobs: echo "auto-merge already enabled" exit 0 fi - gh pr merge "$PR" --repo "$REPO" --auto + if ! out=$(gh pr merge "$PR" --repo "$REPO" --auto 2>&1); then + echo "$out" + if [ "$(gh pr view "$PR" --repo "$REPO" --json autoMergeRequest --jq '.autoMergeRequest != null')" = "true" ]; then + echo "auto-merge already enabled" + exit 0 + fi + exit 1 + fi + printf '%s\n' "$out" From 94711b5337234c13a478edafa786abbb63e87bb2 Mon Sep 17 00:00:00 2001 From: Adam Moussa Date: Fri, 21 Aug 2026 19:46:59 -0400 Subject: [PATCH 3/5] fix(ci): emit ci / ci on the merge-queue branch --- .github/workflows/ci.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c29645c..d41d461 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,6 +3,12 @@ on: pull_request: branches: [main] merge_group: + types: [checks_requested] + # merge_group Actions did not start for #41, so `ci / ci` stayed expected + # on the queue SHA. The queue branch push reports the same check. + push: + branches: + - "gh-readonly-queue/**" permissions: contents: read From a578b31373e3846908ca33d422967af80ae249e0 Mon Sep 17 00:00:00 2001 From: Adam Moussa Date: Fri, 21 Aug 2026 20:23:47 -0400 Subject: [PATCH 4/5] fix(ci): enqueue merge queue as seahaven-bot --- .github/workflows/auto-merge.yaml | 38 +++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/.github/workflows/auto-merge.yaml b/.github/workflows/auto-merge.yaml index f0ef235..a8a074a 100644 --- a/.github/workflows/auto-merge.yaml +++ b/.github/workflows/auto-merge.yaml @@ -4,14 +4,15 @@ on: pull_request: types: [opened, ready_for_review, reopened, synchronize] branches: [main] + pull_request_review: + types: [submitted] concurrency: group: enable-auto-merge-${{ github.event.pull_request.number }} cancel-in-progress: true permissions: - contents: write - pull-requests: write + contents: read jobs: enable: @@ -20,25 +21,44 @@ jobs: && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.user.login != 'renovate[bot]' + && (github.event_name != 'pull_request_review' || github.event.review.state == 'approved') runs-on: ubuntu-latest steps: - - name: Enable squash auto-merge + - name: Mint seahaven-bot token + id: app-token + uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 + with: + app-id: ${{ secrets.SEAHAVEN_BOT_APP_ID }} + private-key: ${{ secrets.SEAHAVEN_BOT_PRIVATE_KEY }} + owner: Sea-Haven-Industries + repositories: ${{ github.event.repository.name }} + + - name: Enqueue or arm auto-merge env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ steps.app-token.outputs.token }} PR: ${{ github.event.pull_request.number }} REPO: ${{ github.repository }} + PR_NODE_ID: ${{ github.event.pull_request.node_id }} run: | set -euo pipefail - if [ "$(gh pr view "$PR" --repo "$REPO" --json autoMergeRequest --jq '.autoMergeRequest != null')" = "true" ]; then - echo "auto-merge already enabled" + in_queue="$(gh api graphql -f query='query($id:ID!) { node(id:$id) { ... on PullRequest { isInMergeQueue } } }' -f id="$PR_NODE_ID" --jq '.data.node.isInMergeQueue')" + if [ "$in_queue" = "true" ]; then + echo "already in merge queue" exit 0 fi - if ! out=$(gh pr merge "$PR" --repo "$REPO" --auto 2>&1); then - echo "$out" + set +e + out="$(gh api graphql -f query='mutation($id:ID!) { enqueuePullRequest(input:{pullRequestId:$id}) { mergeQueueEntry { state } } }' -f id="$PR_NODE_ID" 2>&1)" + status=$? + set -e + if [ "$status" -eq 0 ]; then + printf '%s\n' "$out" + exit 0 + fi + echo "$out" + if ! gh pr merge "$PR" --repo "$REPO" --auto; then if [ "$(gh pr view "$PR" --repo "$REPO" --json autoMergeRequest --jq '.autoMergeRequest != null')" = "true" ]; then echo "auto-merge already enabled" exit 0 fi exit 1 fi - printf '%s\n' "$out" From 2934872266326042a9ccadfa438a7ead6d3596f8 Mon Sep 17 00:00:00 2001 From: Adam Moussa Date: Fri, 21 Aug 2026 20:25:16 -0400 Subject: [PATCH 5/5] fix(ci): re-arm auto-merge as seahaven-bot after failed enqueue --- .github/workflows/auto-merge.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/auto-merge.yaml b/.github/workflows/auto-merge.yaml index a8a074a..633887a 100644 --- a/.github/workflows/auto-merge.yaml +++ b/.github/workflows/auto-merge.yaml @@ -55,6 +55,9 @@ jobs: exit 0 fi echo "$out" + # Re-arm as seahaven-bot. A leftover GITHUB_TOKEN auto-merge would + # enqueue without starting merge_group. + gh pr merge "$PR" --repo "$REPO" --disable-auto || true if ! gh pr merge "$PR" --repo "$REPO" --auto; then if [ "$(gh pr view "$PR" --repo "$REPO" --json autoMergeRequest --jq '.autoMergeRequest != null')" = "true" ]; then echo "auto-merge already enabled"