Skip to content

fix(ci): auto-promote-staging opens a PR + uses merge queue, not direct push - #2247

Merged
HongmingWang-Rabbit merged 1 commit into
stagingfrom
fix/auto-promote-staging-pr-based
Apr 29, 2026
Merged

fix(ci): auto-promote-staging opens a PR + uses merge queue, not direct push#2247
HongmingWang-Rabbit merged 1 commit into
stagingfrom
fix/auto-promote-staging-pr-based

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

Summary

Mirrors the fix in #2234 (which fixed `auto-sync-main-to-staging.yml`) in the reverse direction. Both staging↔main syncs now use the merge queue — no special-case direct-push bypass.

Why

Every tick of `auto-promote-staging.yml` since main's branch protection went stricter has been failing with:

```
remote: error: GH006: Protected branch update failed for refs/heads/main.
remote: - Required status checks were not set by the expected GitHub apps.
remote: - Changes must be made through a pull request.
```

Result: today's 12+ merges to staging never propagated to main; auto-promote ran every tick and failed every tick. Manual `staging → main` PR bridges (#2211, #2236, #2238) had to be opened by hand.

Fix

Step Before After
advance main `git push origin main` (direct, fails branch protection) `gh pr create --base main --head staging` + `gh pr merge --auto --merge`
divergence check manual `git merge-base --is-ancestor` merge queue enforces it
permissions `contents: write` `contents: write` + `pull-requests: write`

The PR's head IS the staging branch — no per-SHA promote branch needed. Idempotent on re-run: looks up the existing open PR by base+head before creating.

Loop safety preserved

When this PR's merge lands on main, `auto-sync-main-to-staging.yml` fires and opens a sync PR back to staging. That sync PR's eventual merge is by GITHUB_TOKEN, which doesn't trigger downstream `workflow_run` events (GitHub Actions safety). So `auto-promote-staging.yml` doesn't re-fire from its own merge landing.

Test plan

  • YAML syntax valid
  • Once merged: next staging push with all required gates green should result in `auto-promote-staging` opening a PR base=main head=staging instead of failing
  • PR lands via merge queue, then auto-sync-main-to-staging fires and lands a sync PR back to staging

Refs

🤖 Generated with Claude Code

…ct push

Mirrors the fix #2234 applied to auto-sync-main-to-staging.yml in the
reverse direction. Both workflows now use the same merge-queue path
that humans use; no special-case bypass.

Why

Every tick of auto-promote-staging.yml since main's branch protection
went stricter has been failing with:

  remote: error: GH006: Protected branch update failed for refs/heads/main.
  remote: - Required status checks "Analyze (go)", "Analyze (javascript-typescript)",
    "Analyze (python)", "Canvas (Next.js)", "Detect changes",
    "E2E API Smoke Test", "Platform (Go)", "Python Lint & Test",
    and "Shellcheck (E2E scripts)" were not set by the expected
    GitHub apps.
  remote: - Changes must be made through a pull request.

The previous version did `git merge --ff-only origin/staging &&
git push origin main` directly. That works against a permissive
branch — it doesn't work against a ruleset that requires checks
satisfied by the expected GitHub apps. Only PR merges through the
queue produce check runs from the right apps.

Result was that today's 12+ merges to staging never propagated to
main; the auto-promote ran every tick and failed every tick, while
operators had to keep opening manual `staging → main` bridges.

Fix

  - Replace the direct git push step with a step that opens (or reuses)
    a PR base=main head=staging and enables auto-merge. The merge queue
    lands it once gates are green on the merge_group ref.
  - The PR's head IS the staging branch (no per-SHA promote branch
    needed) — the whole purpose is "advance main to staging's tip".
  - Add `pull-requests: write` permission so the workflow can call
    gh pr create + gh pr merge --auto.
  - Drop the `git merge-base --is-ancestor` divergence check — the
    merge queue itself enforces branch protection now, and rejects
    the PR if main has diverged from staging history.

Loop safety preserved: when this PR's merge lands on main, it
triggers auto-sync-main-to-staging.yml which opens a sync PR back
to staging. That sync PR's eventual merge is by GITHUB_TOKEN (the
merge queue) which doesn't trigger downstream workflow_run events
— so auto-promote-staging.yml does NOT re-fire from its own merge
landing.

Refs: #2234 (the parallel fix for auto-sync-main-to-staging.yml),
task #142, multiple failing runs visible in
https://github.com/Molecule-AI/molecule-core/actions/workflows/auto-promote-staging.yml
@HongmingWang-Rabbit
HongmingWang-Rabbit added this pull request to the merge queue Apr 29, 2026
Merged via the queue into staging with commit 5753021 Apr 29, 2026
21 checks passed
@HongmingWang-Rabbit
HongmingWang-Rabbit deleted the fix/auto-promote-staging-pr-based branch April 29, 2026 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant