Final project: from commit to production with gates and rollback

DevOps, Hands On2 to 3 hoursFreeWritten 23 November 2026By Cloud Hands On

In this task you'll join everything in this section into one pipeline from commit to production.

The final project builds the pipeline a small team would really use for SS Kaiser's stock-check API: fast checks on every pull request, a versioned build made once, an image with an SBOM and provenance, deployment to a test environment, an approval, deployment to production with an automatic rollback, and a record you can measure.

Afterwards you can answer the questions an auditor or a new team member asks: what's running, where it came from, who approved it, and how quickly a change reaches users (lead time) and how often (deployment frequency).

Example. SS Kaiser's stock-check API: a pull request gets lint, a test matrix and integration tests in under eight minutes. Merging builds stock-api once, tagged with the SHA and attested. It deploys to test, waits for a release manager's approval in the production environment, deploys to production and rolls back if the smoke test fails.

Before you start

You need: A free GitHub account and a public test repository (Actions minutes are free for public repositories). Time: 2 to 3 hours.

Where to look

  1. Repository
  2. .github/workflows
  3. Settings
  4. Environments

Steps

  1. Pull request checks: lint and a test matrix side by side, integration tests with a PostgreSQL service, all cached, with concurrency cancelling old runs.
  2. On main: build the image once, push it to GHCR tagged with the SHA, produce an SBOM and attest the image.
  3. Deploy to a test environment (a kind cluster in the runner is fine) and run the smoke test.
  4. Create a production environment with yourself as required reviewer, and make the production job verify the attestation before deploying the same digest.Required reviewers are free on public repositories.
  5. Make the production job roll back automatically when rollout status or the smoke test fails. Test it once with a broken image.
  6. Measure: list the last ten production deployments with gh api repos/OWNER/REPO/deployments and work out the average time from commit to deployment.These are two of the four DORA measures.
  7. Write a one-page report: the pipeline diagram, the gates, the rollback test and your two DORA numbers.

Commands

# Promote the exact tested image by digest
IMAGE=ghcr.io/OWNER/stock-api@${{ needs.build.outputs.digest }}
gh attestation verify oci://$IMAGE -R OWNER/REPO
kubectl set image deploy/stock-api api=$IMAGE
kubectl rollout status deploy/stock-api --timeout=120s || { kubectl rollout undo deploy/stock-api; exit 1; }

# DORA: recent production deployments
gh api repos/OWNER/REPO/deployments -f environment=production --jq '.[] | [.sha[0:7], .created_at] | @tsv'

Watch out for

Cost
Free in a public repository.
Security
Least privilege per job, OIDC for any real cloud, environment secrets only for production, and actions pinned to SHAs.
Common mistakes
Building again for production instead of promoting the tested image, and an approval step no one is notified about.

Clean up

Delete test releases and the GHCR image, then the repository: gh repo delete OWNER/REPO --yes.

Words to know

Lead time for changes
Time from a commit to it running in production.
Deployment frequency
How often you deploy to production.
Gate
A check or approval a change must pass before the next stage.

Tick off each step and track your progress in the guide.

Open this task in DevOps, Hands On

Keep going