Pipeline Automation for Branch-Based Environment Management
Introduction In our previous article, we explored three models for handling deployment environments in version control: branches, forked repositories, and
In our previous article, we explored three models for handling deployment environments in version control: branches, forked repositories, and trunk-based development (TBD). This post dives deep into pipeline automation for the branching model—the most traditional approach—using tools like GitHub Actions and GitLab CI/CD.
develop
, staging
, main
) are branches in a single repo.develop
.develop
is merged into staging
.staging
merges into main
for production.develop
→ Dev/Test environmentstaging
→ Stagingmain
→ Production 1# .github/workflows/deploy.yml
2name: Deploy on Branch
3
4on:
5 push:
6 branches:
7 - develop
8 - staging
9 - main
10
11jobs:
12 deploy:
13 runs-on: ubuntu-latest
14 steps:
15 - uses: actions/checkout@v3
16 - name: Deploy
17 env:
18 ENV_NAME: ${{ github.ref_name }}
19 run: ./deploy.sh $ENV_NAME
1stages:
2 - deploy
3
4deploy:
5 stage: deploy
6 variables:
7 ENV_NAME: "${CI_COMMIT_REF_NAME}"
8 script:
9 - ./deploy.sh $ENV_NAME
10 only:
11 - develop
12 - staging
13 - main
Branch-based CI/CD remains easy to visualize, automate, and scale for most teams—especially those not ready for TBD. However, the merge overhead and config drift can be real: We will also cover how Trunk-Based Development automates environments with even less friction.
You are interested in our courses or you simply have a question that needs answering? You can contact us at anytime! We will do our best to answer all your questions.
Contact us