mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 13:53:15 +00:00
* ci: re-home prod promotion into a gated promote-to-main workflow Migrate the prod-deploy gate to managed LangGraph Cloud (git-connected to `main`) + Vercel. Under managed, a push to `main` auto-deploys prod, so the dev -> main fast-forward IS the prod deploy trigger -- the bespoke AWS CD step is obsolete and already gone from this workflow. Re-home `promote-dev-to-prod.yml` -> `promote-to-main.yml`: - gate the promote job on the `prod` GitHub Environment (required reviewer amoussa1229), restoring the manual prod-approval that the retired AWS CD job used to carry; - drop the nightly auto-promote cron -- a scheduled auto-promotion conflicts with a manual approval gate now that the push deploys prod; promotion is workflow_dispatch only; - keep the dev-HEAD-fully-green precondition and the seahaven-promotion App fast-forward push (sole non-admin bypass actor on `main` ruleset 18238334). Update the companion check-dev-green.sh filename reference. * ci: refuse promote-to-main dispatch from any ref other than dev Defense-in-depth atop the already-pinned `ref: dev` checkout: workflow_dispatch runs the workflow definition from the launched ref, so reject a non-dev dispatch before the App token is minted. Surfaced by the GPT-4.1 cross-review of #63.
101 lines
4.3 KiB
Bash
Executable file
101 lines
4.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Promotion gate: refuse to promote a dev HEAD that is not fully green.
|
|
#
|
|
# Reads check-runs on stdin — one
|
|
# name<US>status<US>conclusion<US>details_url
|
|
# per line, fields separated by ASCII Unit Separator (0x1F) — so it is unit-testable
|
|
# WITHOUT GitHub. promote-to-main.yml pipes the live `gh api .../check-runs`
|
|
# output in. 0x1F (not TAB) is used deliberately: TAB is IFS-whitespace, so an empty
|
|
# conclusion (every in_progress check has a null conclusion) would collapse and shift
|
|
# the columns — which would make the promote run fail to exclude itself. 0x1F is
|
|
# non-whitespace, so `read` preserves empty fields and the columns stay aligned.
|
|
#
|
|
# A dev HEAD is promotable ONLY when BOTH hold:
|
|
# 1. every present check-run is completed with a passing conclusion
|
|
# (success/neutral/skipped); any pending/failed/cancelled/timed_out check BLOCKS.
|
|
# 2. every check named in REQUIRED_CHECKS is present AND concluded "success".
|
|
# This positive allow-list is what stops a partial-signal promotion — e.g. a
|
|
# commit pushed with [skip ci] (no CI check-runs) that still carries one
|
|
# unrelated green check, or a required check silently renamed/dropped. The gate
|
|
# FAILS SAFE: a missing required check blocks rather than promotes.
|
|
#
|
|
# Self-exclusion: the promotion workflow's OWN in-progress check-run is dropped by
|
|
# EXCLUDE_RUN_ID (its github.run_id, matched in the check-run details_url) — an
|
|
# unforgeable identity, NOT a mutable check name. A check that merely happens to be
|
|
# named "promote" can no longer hide a real failing/required check.
|
|
set -euo pipefail
|
|
|
|
EXCLUDE_RUN_ID="${EXCLUDE_RUN_ID:-}"
|
|
# Name of the promotion workflow's own check-run (its job id). STALE check-runs from
|
|
# prior FAILED promote runs on the same dev HEAD are dropped in the loop so they don't
|
|
# self-poison the "every present check must be green" rule. Configurable so a job
|
|
# rename doesn't silently break the exclusion.
|
|
PROMOTE_CHECK_NAME="${PROMOTE_CHECK_NAME:-promote}"
|
|
# Mandatory checks (one per line). Defaults to the CI suite, which runs on
|
|
# every push to dev (see ci.yml). Keep in sync with those job names; if a name
|
|
# drifts the gate blocks (fails safe) until the list is updated.
|
|
REQUIRED_CHECKS="${REQUIRED_CHECKS:-Lint
|
|
Format check
|
|
Unit tests
|
|
Playwright E2E}"
|
|
|
|
declare -A GREEN
|
|
seen=0
|
|
bad=0
|
|
while IFS=$'\037' read -r name status conclusion details_url; do
|
|
[ -n "${name:-}" ] || continue
|
|
# drop the promotion run's own check-run by run id (never by name).
|
|
if [ -n "${EXCLUDE_RUN_ID}" ] && \
|
|
[ "${details_url}" != "${details_url#*/runs/"${EXCLUDE_RUN_ID}"/}" ]; then
|
|
continue
|
|
fi
|
|
# Also drop ANY check-run from the promotion workflow itself — not just THIS run
|
|
# (above) but STALE ones left by prior FAILED promote runs on the same dev HEAD,
|
|
# which would otherwise self-poison this gate forever (the failure check-run is
|
|
# immutable on the commit). Scoped to name==PROMOTE_CHECK_NAME AND a GitHub Actions
|
|
# run URL (details_url under /actions/runs/) so an EXTERNAL app cannot hide a real
|
|
# failing check by naming it "promote". The positive REQUIRED_CHECKS allow-list
|
|
# below is the authoritative signal regardless — "promote" is never a required check.
|
|
if [ "${name}" = "${PROMOTE_CHECK_NAME}" ] && \
|
|
[ "${details_url}" != "${details_url#*/actions/runs/}" ]; then
|
|
continue
|
|
fi
|
|
seen=$((seen + 1))
|
|
if [ "${status}" != "completed" ]; then
|
|
echo "BLOCK: check '${name}' is '${status}' (not completed)" >&2
|
|
bad=1
|
|
continue
|
|
fi
|
|
case "${conclusion}" in
|
|
success)
|
|
GREEN["${name}"]=1
|
|
echo "ok: ${name} (success)" ;;
|
|
neutral | skipped)
|
|
echo "ok: ${name} (${conclusion})" ;;
|
|
*)
|
|
echo "BLOCK: check '${name}' concluded '${conclusion:-<none>}'" >&2
|
|
bad=1 ;;
|
|
esac
|
|
done
|
|
|
|
if [ "${seen}" -eq 0 ]; then
|
|
echo "BLOCK: no check-runs found for this commit — refusing to promote an unverified dev HEAD" >&2
|
|
exit 1
|
|
fi
|
|
|
|
missing=0
|
|
while IFS= read -r req; do
|
|
[ -n "${req}" ] || continue
|
|
if [ -z "${GREEN[${req}]:-}" ]; then
|
|
echo "BLOCK: required check '${req}' is missing or not successful on dev HEAD" >&2
|
|
missing=1
|
|
fi
|
|
done <<EOF
|
|
${REQUIRED_CHECKS}
|
|
EOF
|
|
|
|
if [ "${bad}" -ne 0 ] || [ "${missing}" -ne 0 ]; then
|
|
echo "BLOCK: dev HEAD is not promotable (see reasons above)" >&2
|
|
exit 1
|
|
fi
|
|
echo "PASS: ${seen} check(s) present, all green; all required checks present + successful."
|