Pipeline
Trunk-based delivery. Build once, then promote one image digest and one client bundle through dev, staging and prod.
Every merge to main is a release candidate. The pipeline builds it once: one server image, identified by its manifest digest, and one client bundle. It then releases that pair to dev, staging and prod, in that order. Each environment runs a rolling ECS update with the deployment circuit breaker and the 5xx-ratio alarm rollback from Task 1, then checks the result itself before it moves on.
The pipeline
| Workflow | Trigger | What it does |
|---|---|---|
ci.yml |
Pull request into main |
Quality gates. One required check, ci-ok. See Quality gates. |
deploy.yml |
Push to main (not infrastructure/** or docs/**), or a manual run |
Builds once, then calls _release.yml for dev, staging and prod. |
_release.yml |
Called by deploy.yml and rollback.yml |
Puts one release into one environment. The only deploy implementation. |
rollback.yml |
Manual | Releases an older, known-good SHA through _release.yml and freezes deploys. See Rollback. |
unfreeze.yml |
Manual | Clears the freeze after the fix is on main. |
terraform.yml, _terraform.yml |
Pull request or push under infrastructure/ |
Plan on pull requests; plan, then apply of that same saved plan, on main. |
Every workflow starts with permissions: {} and gives each job only what it needs. id-token: write appears only on jobs that assume an AWS role. Every action is pinned to a full commit SHA. Every tool image (Trivy, gitleaks, tflint, actionlint, shellcheck, the Python base image) is pinned by digest.
Build once
Each environment has its own AWS account, so each has its own ECR registry. docker save and docker load can change a digest, so the pipeline never uses them.
Build an OCI archive
scripts/ci/build-server-image.sh runs docker buildx build --target production --build-arg RELEASE_SHA=$GITHUB_SHA --provenance=false --sbom=false --output type=oci. Without attestations the archive holds one image manifest, not an index. The script fails unless the build’s digest equals the manifest digest in the archive’s index.json. RELEASE_SHA becomes the service.version of every metric, span and log line, so the image reports its own release whichever environment runs it.
Copy it into each account unchanged
scripts/ci/push-image.sh runs skopeo copy --preserve-digests oci-archive:… docker://<repo>:<sha>. skopeo fails rather than write a manifest with a different digest. The script then reads the digest back from ECR and fails on any difference.
Deploy by digest
The task definition gets repository@sha256:…, never a tag. The tag (the commit SHA) exists only so that people can find the image.
The client bundle is built once too. The API base is relative (/api), so one bundle is correct in every environment. The build’s only input is VITE_RELEASE_SHA, which goes into <meta name="release"> in index.html so that the post-release check can read back which release CloudFront serves.
One release, step by step
_release.yml runs one job in the target GitHub Environment. The steps that change what users reach come after every check.
Check the freeze flag
freeze.sh check. If rollback.yml froze this environment, stop with the reason.Bring the build into this account
releases/<sha>/ in the site bucket. Nothing users reach changes yet.Check both halves exist
check-release-artifacts.sh: the digest is in ECR and releases/<sha>/index.html is in the bucket.Start the release record
in_progress.Register a task definition
release-sha=<sha>.Update the service and wait
Verify
rolloutState COMPLETED.Smoke test
Publish the client
index.html (no-cache), then invalidate /index.html.Check CloudFront
/ and /index.html serve this SHA, and every referenced asset loads.Record and report
Set the freeze flag
Check both halves still exist
releases/<sha>/index.html in the bucket.Start the release record
rollback, with the reason.Publish the old client first
Register, update, wait, verify, smoke test
Check CloudFront
/ and /index.html serve the target SHA.Record and report
rollback.yml marks the releases it replaced inactive.Release records
Each release attempt in each environment is a GitHub Deployment with task: release, ref set to the release SHA, and a payload with the image digest, the kind and the reason. scripts/ci/release-record.sh writes them with auto_inactive: false, so the latest status is always the result of that release:
| Latest status | Meaning |
|---|---|
success |
Every step passed. A valid rollback target. |
failure |
A step failed after the first change. |
error |
The job was cancelled, for example by a rollback. |
inactive |
A later rollback replaced this release. |
in_progress |
Running, or the runner died. Not a rollback target. |
The jobs set environment.deployment: false, so GitHub does not add its own record. GitHub’s record would carry the workflow’s commit, which is wrong for a rollback.
Concurrency
| Group | Used by | cancel-in-progress |
Why |
|---|---|---|---|
deploy-<env> |
deploy.yml (each environment) |
false |
A deploy never stops another deploy halfway. GitHub’s default queue keeps one pending run, and a newer run replaces it. On trunk the newer commit contains the older one, so nothing is lost. |
deploy-<env> |
rollback.yml |
true |
A rollback does not wait behind the deploy that may be causing the incident. Because it can stop a deploy at any step, it always sets both client and server. |
deploy-<env> |
unfreeze.yml |
false |
Waits behind a running rollback. |
terraform-<env> |
terraform.yml on main |
false |
Separate from deploys, so a rollback never cancels an apply. One group covers plan and apply together. |
ci-<pr> |
ci.yml |
true |
A new push makes the old run useless. |
Scripts
Each script does one step, uses set -euo pipefail, and takes its inputs from environment variables named in its header.
| Script | Step |
|---|---|
build-server-image.sh, push-image.sh |
Build once; copy into ECR, keeping the digest |
upload-client.sh, publish-client.sh, check-site.sh |
Archive the bundle; make it live; confirm through CloudFront |
check-release-artifacts.sh |
Stop before any change if the image or bundle is missing |
register-task-definition.sh, wait-for-service.sh, verify-deployment.sh |
ECS revision, rollout wait, rollout result |
generate-traffic.sh, smoke.py |
Alarm data during the wait; API and WebSocket smoke test |
freeze.sh, release-record.sh, resolve-rollback-target.sh |
Freeze flag; release history; rollback target |
notify-slack.sh |
Release result to Slack |
changed-paths.sh, terraform-plan.sh, terraform-apply.sh |
CI path filter; Terraform |