How to Promote a Build Through Environments by Branch
Promotion by branch advances the exact commit from one environment branch to the next, so production runs the artifact staging already tested.
Environment promotion means moving a validated commit forward, not rebuilding it. Merge staging into production (or use a tag) so the deployed artifact is byte-for-byte what you tested. CI deploys on push to each environment branch.
Steps
- Deploy and validate on the staging branch.
- Promote by merging staging into production (fast-forward if possible).
- Deploy the same commit to production on push.
- Reuse the already-built artifact rather than rebuilding from source.
Promote and deploy
Terminal
# Promote staging to production
git checkout production
git merge --ff-only staging
git push origin production
# production workflow reuses the prior artifact
# on: push: branches: [production]
# - uses: actions/download-artifact@v4
# with: { name: app-build }
# - run: ./deploy.sh productionGotchas
- Rebuilding at each stage can produce a different artifact; promote the built one.
- A non-fast-forward merge into production means the branches diverged; investigate before deploying.
Related guides
How to Set Up CI for GitLab Flow With Environment BranchesUse GitLab Flow environment branches (main, staging, production) so a merge into each branch promotes the sam…
How to Deploy per Branch by Mapping Branch to EnvironmentMap each branch to a deployment environment in GitHub Actions so develop deploys to staging and main deploys…
How to Set Up CI for Release BranchesCut a release branch, run extended integration and packaging jobs on it, and deploy the tagged build, keeping…