SR-005 — Release Promotion Pipeline: System Requirements

By Engineering Team•November 30, 2026•5 min read
Metadata Details
System Name astro-static-site Release Promotion Pipeline Specifications
Document ID SR-STATIC-005
Author Engineering Team
Status Implemented

Traces to BRD-005 — Controlled Release Promotion. This document owns everything about releasing: when a workflow runs, the guards, and the order between environments and between infrastructure and site. What the infrastructure run plans and applies is in SR-006, what the app run builds and deploys in SR-007, and which job reads which value in SR-008. Cite requirement IDs with the document ID (e.g. SR-005 SR-F-04).


1. Workflows

Workflow Started by Inputs Does
infra.yml A person, Run workflow on main sha, target, action (plan or apply) Guard, scan, tofu plan for the target; with apply, applies that plan and copies the state to history/
app.yml A person, Run workflow on main sha, target Guard, scan, build for the target; nonprod stores its build, prod compares with it; deploys

No workflow runs on a push, a pull request or a schedule. Branches: feature/* merge into dev for the developer’s own testing, and dev or hotfix/* reach main by pull request. Only commits on main are released.


2. Functional System Requirements

ID Description Traceability
SR-F-01 (Plan at Release) infra.yml scans the commit and runs tofu plan for the target’s root in a job bound to that GitHub environment. With action: plan it stops there and changes nothing. BR-1.1, BR-1.1 (BRD-004)
SR-F-02 (Build at Release) app.yml scans the commit and builds the site once for the target, in a job bound to that GitHub environment. The media origin and the environment’s own Analytics measurement ID come from the target’s vault (config/image-base-url, config/ga-measurement-id). A nonprod run stores the build (dist.tar.gz, SHA256SUMS, media origin) as site-nonprod-<sha> for 30 days. BR-1.1, BR-1.1 (BRD-004)
SR-F-03 (Prod Matches the Tested Build) A prod run downloads site-nonprod-<sha>, verifies its checksum, and fails unless its own build differs from it only in the media origin, the Analytics tags and the script hashes that follow from them (scripts/compare-builds.sh). BR-1.2
SR-F-10 (Media Promotion) Before the Pages deploy, app.yml runs scripts/promote-media.sh: it lists every <media origin>/images/... link in the build to deploy (prod: the stored nonprod build), checks against one listing of the non-production media bucket that each exists, and copies them into the target environment’s media bucket with S3 CopyObject, inside R2, several at a time. A nonprod run copies onto itself each image older than a day, which restarts its expiry, and stores the images’ ETags with site-nonprod-<sha>; a prod run fails unless every source ETag equals the stored one. A missing or changed image stops the run, naming it. BR-1.2, BR-1.3
SR-F-04 (Apply What Was Planned) infra.yml with action: apply applies the plan made in the same run. The person reads the plan of a plan run of the same commit and target first. BR-2.2
SR-F-05 (Manual Release Only) Every plan, apply, build and deployment starts from a Run workflow a person starts on main with the commit SHA and the target. BR-2.2, BR-4.2
SR-F-06 (Release Record) The run summary names the commit, the target and the actor. A successful apply uploads promoted-infra-<target>-<infrastructure change>, a successful deployment promoted-app-<target>-<sha>, kept 90 days. BR-2.2
SR-F-07 (Guards) deploy/scripts/promote-guard.sh refuses a run unless it was started on main and the SHA is a commit on main. For prod: infra needs the marker of the same infrastructure change in nonprod; app needs promoted-app-nonprod-<sha> and an unexpired site-nonprod-<sha>. BR-2.1
SR-F-08 (Independent Life Cycles) promote-guard.sh works out the infrastructure change of a commit (the newest commit in its history that changed deploy/infra/, deploy/modules/ or deploy/scripts/) for an infra run only. An app run never checks infrastructure markers, so the site is released on its own schedule. When a site change needs new infrastructure, the person releases the infrastructure for that target first. BR-3.1, BR-3.2
SR-F-09 (State Copies) After a successful apply, infra.yml copies changed state to history/ with deploy/scripts/snapshot-state.sh; a failed apply copies nothing. setup-prod.yml in the setup layer copies its own state after a successful apply. BR-4.1

3. Non-Functional Requirements

ID Description Traceability
SR-NF-01 (No Automatic Runs) No workflow has a push, pull_request or schedule trigger. BR-4.2
SR-NF-02 (One Target per Run) A run builds or plans for one environment only; nonprod and prod are never built or planned in the same run. BR-3.1, BR-4.2
SR-NF-03 (Caches) npm, the Astro content cache, the Trivy database and the OpenTofu provider cache are restored between runs. BR-4.2
SR-NF-04 (One Change at a Time) Runs hold the concurrency groups infra-<target> and app-<target>, never cancelled in progress. BR-3.2
SR-NF-05 (Fail Closed) A guard that cannot be checked, a scan finding, a checksum or comparison mismatch, a failed plan or apply stops the run; the marker is uploaded only as the last step. BR-2.1, BR-2.2
SR-NF-08 (Media Copy Scope) The copy uses the environment’s media copy key pair, loaded from its vault after the build and cleared after the step. It holds object read on the non-production media bucket and object write on the environment’s own media bucket, nothing else. The images never pass through the runner. BR-2.2
SR-NF-06 (Values from Inputs, Not Scripts) Run inputs reach scripts as environment variables, never expanded inside a shell command. BR-2.2
SR-NF-07 (Stated Limits) GitHub enforces required reviewers on a private repository only on GitHub Enterprise, so the person starting the run is the approval. A stored nonprod build expires after 30 days and markers after 90: after that, promote to nonprod again, or apply the infrastructure again (its plan shows no changes). BR-2.2