Skip to main content

Artifact Promotion

Artifact promotion is building an image or binary once and moving that same immutable artifact through dev, staging, and production instead of rebuilding for each environment.

Understanding Artifact Promotion

What Is Artifact Promotion and Why Does It Matter

Artifact promotion means one build produces one artifact, identified by an immutable reference such as an image digest, and that exact artifact is deployed to every environment in turn. Only the configuration changes between environments, never the bits.

If production is a fresh rebuild from the same source, a base image or dependency can resolve differently, so the production image is technically untested. Promotion removes that gap and gives you a clean chain of custody: this image came from this commit, passed these checks, and was approved by these people.

Promotion Flow

flowchart TD A[Build once from commit] --> B[Push to registry, record digest] B --> C[Test and scan that digest] C --> D[Deploy digest to staging] D --> E[Approve and deploy to production] classDef build fill:#326CE5,color:#FFFFFF classDef gate fill:#8B5CF6,color:#FFFFFF classDef prod fill:#10B981,color:#FFFFFF class A,B build class C,D gate class E prod

Tags vs Digests

Reference Mutable?
payment-api:latest Yes, can move at any time
payment-api:v1.2.3 Yes, unless the registry enforces immutability
payment-api@sha256:f8a2... No, it is a hash of the content

Implementation with Digest Pinning

YAML
jobs:
build:
runs-on: ubuntu-latest
outputs:
digest: ${{ steps.push.outputs.digest }}
steps:
- uses: actions/checkout@v4
- id: push
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ env.ECR_REGISTRY }}/payment-api:${{ github.sha }}
deploy-staging:
needs: build
runs-on: ubuntu-latest
environment: staging
steps:
- run: |
helm upgrade --install payment-api ./charts/payment-api \
--set image.repository=$ECR_REGISTRY/payment-api \
--set image.digest=${{ needs.build.outputs.digest }} \
-n payment-api-staging --atomic
deploy-production:
needs: [build, deploy-staging]
runs-on: ubuntu-latest
environment: production
steps:
- run: |
helm upgrade --install payment-api ./charts/payment-api \
--set image.repository=$ECR_REGISTRY/payment-api \
--set image.digest=${{ needs.build.outputs.digest }} \
-n payment-api-production --atomic

The chart must render repository@digest when a digest is set. Both environments receive the same digest from the same build job.

Externalise Configuration

Promotion only works if the image is environment-neutral. Pass API URLs, feature flags, and credentials through environment variables, ConfigMaps, or a secrets manager at deploy time. Baking them in at build time forces one build per environment and defeats the point.

Troubleshooting

Symptom Check What to Look For
Staging and prod behave differently Image reference per environment Different digests or a moved tag
Cannot trace a running image Labels and tags Missing commit SHA label
Deploy pulls an unexpected image Tag strategy Anything deploying latest
Tip

Add labels such as git.commit and ci.run at build time. They are readable with docker inspect and link a running container to its exact commit and pipeline run.

Remember

A digest is the only truly immutable image reference. Enable tag immutability on the registry as a second safety net.

Security

Promotion is also a supply chain control. Sign the digest (for example with cosign) and verify the signature at deploy time so only images your pipeline built can run.

Common Mistake

Tagging with latest and deploying that tag. It can point at a different image between your test run and your deploy. Deploy by digest or commit SHA.

Frequently Asked Questions

What risk does artifact promotion actually remove?

It removes build-time drift. If each environment rebuilds, a dependency can resolve to a new version between the staging build and the production build, causing a works-in-staging, fails-in-prod bug that has nothing to do with your code.

Is a version tag like v1.2.3 enough to promote safely?

Only if the registry enforces tag immutability. Otherwise a tag can be re-pointed, so the safest reference is the content digest recorded at build time.

How do I handle different settings per environment without rebuilding?

Externalise configuration. Inject values through environment variables, mounted ConfigMaps, or a secrets manager so the same image runs everywhere and only its configuration differs.

Found a mistake, an outdated step or a broken link?