Advanced
Searching inHow-to guides
How to search
  • Type the task in your own words (find port, open firewall, disk full) or paste an error message in quotes.
  • Choose "Quick answer" to see only the commands, or an area to stay in one field.
  • "two words" finds the exact phrase.
  • Plain words find names, texts and examples.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search
Try:

How-to 245CI/CD · Delivery

How to promote a release from staging to production

"It worked in staging" means little if production gets a different build. Safe promotion moves the same artifact — the same image digest — from staging to production, after tests and an approval, with a record of who promoted what and when. This how-to sets up build-once-promote-many with image digests, a GitOps repository per environment, and an approval gate in GitHub Actions.

  • 5 Lessons
  • 4 Commands

$ run as a normal user# run as root (or with sudo)

245.1

The quick answer

.github/workflows/promote.yml
name: promote
on:
  workflow_dispatch:
    inputs:
      digest:
        description: "Image digest tested in staging (sha256:...)"
        required: true
jobs:
  production:
    runs-on: ubuntu-latest
    environment: production
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4
      - run: |
          cd envs/prod
          kustomize edit set image registry.example.com/shop/api@${{ inputs.digest }}
          git config user.name "release-bot"
          git config user.email "release-bot@example.com"
          git commit -am "prod: shop/api ${{ inputs.digest }}"
          git push

245.2

Step by step

  1. Build once — CI builds the image one time per commit and pushes it; the build output is the digest (sha256:…), which never changes (a tag like :latest or even :1.4.2 can be moved).
  2. Deploy to staging by digest — the staging overlay in the GitOps repo gets image@sha256:…; Argo CD or Flux deploys it.
  3. Test in staging — automatic smoke and integration tests, plus manual checks if needed. Record the result (a check run or a comment).
  4. Promote the same digest (quick answer) — a workflow updates the production overlay with the tested digest. Nothing is rebuilt.
  5. Approval gate — the production environment in GitHub (Settings → Environments) with required reviewers: the job waits until a reviewer approves. Optionally a wait timer and allowed branches.
  6. Promotion is a Git commit — the production repo history shows who promoted which digest and when. Rollback = git revert of that commit.
  7. Promote the config too — keep environment differences small and explicit (replicas, URLs, secrets references in overlays); everything else is shared.
  8. Stronger guarantees — sign images (Cosign) in CI and let the production cluster accept only signed images from your pipeline (Kyverno/admission policy).

Commands in this lesson

245.3

Check that it worked

The image digest running in production (kubectl -n shop get deploy api -o jsonpath='{.spec.template.spec.containers[0].image}') is exactly the digest tested in staging; the promote run shows the reviewer's approval; the GitOps repo has one commit per promotion.

245.4

Common problems

ProblemCauseFix
Production behaves differently than stagingRebuilt image or moved tag.Deploy by digest; never rebuild for production.
Promote job runs without approvalEnvironment not protected.Required reviewers on the production environment.
git push rejected in the workflowMissing contents: write or branch protection.Permission in the job; allow the bot or use a PR + auto-merge.
Rollback is slowRollback means a new build.Revert the promotion commit; the old digest is still in the registry.
Old images deleted by cleanupRegistry retention removed the digest.Keep images that are deployed or recently promoted.
Config drift between environmentsBig differences in overlays.Keep overlays small; review them with the code.

Commands in this lesson

245.5

Go further

1Why deploy by image digest and not by tag?

A digest always points to exactly the same image; a tag can be moved to another build.

2How do you roll back a promotion in a GitOps setup?

Revert the promotion commit; the GitOps tool deploys the previous digest again.

All commands in this chapter