mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-01 09:43:14 +00:00
Some checks are pending
Build & publish app artifacts / Publish + deploy (dev) (push) Waiting to run
Build & publish app artifacts / Publish + deploy (prod) (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Format check (push) Waiting to run
CI / Unit tests (push) Waiting to run
CI / Playwright E2E (push) Waiting to run
The nightly promote fast-forwards main to a fully-green dev HEAD, but the push (as github-actions[bot]) is rejected by the main ruleset: it requires PRs + a status check and the default token is not a bypass actor, so a direct ref push can never land regardless of fast-forwardability. The prior comment claiming protection 'only rejects non-FF' was wrong. Mint a GitHub App installation token (actions/create-github-app-token, SHA-pinned) and push with it; the App must be added to the main ruleset's bypass actors out-of-band. The promoted commit already passed every check on dev (gated by check-dev-green.sh), so re-gating it via a PR on main is redundant. Also fix a gate self-poison: a stale failed 'promote' check-run from a prior run on the same dev HEAD blocked every subsequent gate run (it was excluded only by the current run_id). Exclude prior promote check-runs too, scoped to name=='promote' AND a /actions/runs/ details_url so an external app cannot hide a real failing check by naming it 'promote'; the positive REQUIRED_CHECKS allow-list stays authoritative. Gates: GPT-4.1 cross-review APPROVE (no security regression). Unit-tested: stale promote ignored -> PASS; real failure / external promote / missing required check -> BLOCK. shellcheck clean (also fixed a pre-existing SC2295 on the run_id match).
68 lines
3 KiB
YAML
68 lines
3 KiB
YAML
name: Promote dev to main (prod)
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "0 8 * * *"
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: promote-dev-to-main
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
promote:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
checks: read
|
|
steps:
|
|
# Mint a GitHub App installation token for the protected-branch push below.
|
|
# A plain ref push by github-actions[bot] is REJECTED by the `main` ruleset
|
|
# (PRs required + a required status check; the default token is not a bypass
|
|
# actor). The App behind these secrets MUST be added to the `main` ruleset's
|
|
# bypass actors; the push is then accepted and attributed to the App (not a
|
|
# human PAT). The promoted commit already passed every check on dev (gated
|
|
# below), so re-gating it via a PR on main would be redundant.
|
|
- name: Mint app token for the protected-branch push
|
|
id: app-token
|
|
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
|
with:
|
|
app-id: ${{ secrets.PROMOTE_APP_ID }}
|
|
private-key: ${{ secrets.PROMOTE_APP_PRIVATE_KEY }}
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
ref: dev
|
|
fetch-depth: 0
|
|
# Persist the App token as the git credential so the fast-forward push uses
|
|
# the bypass-actor identity (not the default github-actions[bot]).
|
|
token: ${{ steps.app-token.outputs.token }}
|
|
- name: Require dev HEAD fully green
|
|
# Hard precondition: every check-run on the dev HEAD commit must be
|
|
# completed + passing before we let it become prod. A red OR still-pending
|
|
# check blocks the promotion. The promotion workflow's OWN check-runs are
|
|
# excluded by the gate (this run by id, plus any STALE prior promote runs by
|
|
# name + Actions URL) so the gate can't deadlock on itself.
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
# exclude THIS run's own check-run by its run id (not by name).
|
|
EXCLUDE_RUN_ID: ${{ github.run_id }}
|
|
run: |
|
|
SHA="$(git rev-parse HEAD)"
|
|
echo "dev HEAD = ${SHA}"
|
|
gh api --paginate "repos/${GITHUB_REPOSITORY}/commits/${SHA}/check-runs" \
|
|
-q '.check_runs[] | [.name, .status, (.conclusion // ""), (.details_url // "")] | join("\u001f")' \
|
|
| bash .github/scripts/check-dev-green.sh
|
|
- name: Fast-forward main (PROD) to dev
|
|
# main is the production branch. A direct ref push is normally rejected by the
|
|
# `main` ruleset (PRs required), so this succeeds only because the App minted
|
|
# above is a bypass actor. The push is fast-forward-only, so a diverged main
|
|
# fails loudly rather than force-updating.
|
|
#
|
|
# SECURITY: this is the LAST step on purpose. The App token persists as the
|
|
# git credential after checkout — do not add steps after this push that run
|
|
# untrusted code or could echo the credential.
|
|
run: |
|
|
git push origin HEAD:refs/heads/main
|