00004 — Infrastructure Pipeline

By Engineering Team•November 29, 2026•4 min read

Implements SR-006. When a release runs, the guards and the order between environments are in 00006 — GitHub Workflow Architecture; this page covers only what infra.yml does. What the infrastructure contains is in 00001.


1. Flow

Infrastructure pipeline: a person runs the workflow on main with a SHA, target and action; if the guards pass the commit is scanned and planned; with action plan the run stops and nothing changes; with action apply the plan is applied, and only if the apply succeeded the state is copied to history and the promotion recorded


2. Steps

Step What happens Requirements
Guard See 00006, guards. SR-005 SR-F-07
Scan Trivy scans the commit for vulnerabilities, secrets and misconfiguration; a high or critical finding stops the run. SR-006 SR-F-02
Init In a job bound to the target’s GitHub environment, after its values are loaded from the target’s vault through the read-only service account: tofu init with a read-only lock file; the state bucket’s address comes from the vault, like every other value. SR-006 SR-F-05, SR-F-10
Plan tofu plan -out, printed in the log. With action: plan, the run ends here and nothing changes. SR-006 SR-F-03, SR-005 SR-F-01
Apply With action: apply, that plan is applied. SR-006 SR-F-03, SR-005 SR-F-04
Copy Only if the apply succeeded, deploy/scripts/snapshot-state.sh copies every changed state to history/. SR-005 SR-F-09
Record The marker promoted-infra-<target>-<infrastructure change> is uploaded last. SR-005 SR-F-06

Run plan first and read it, then apply for the same commit and target. The non-production root is also applied this way after its first setup from the site’s dev container.


3. Encrypted state and plans

State and plans never leave the runner unencrypted (SR-006 SR-F-09). OpenTofu’s encryption block, enforced for both, derives the key from the environment’s state passphrase with PBKDF2 and encrypts with AES-GCM; only the jobs of that environment hold the passphrase. The live state is under workloads/; copies are under history/, which a retention lock protects from deletion and overwrite. A copy is a server-side copy, named after the time and a digest of the content, and skipped when that content already has a copy. One run per environment changes state at a time.