Trunk-based Development Video Guide¶
The video explains the CI/CD workflow using Trunk-Based Development with GitLab and ArgoCD, covering how code changes move from commit to production through automated pipelines, versioning, and environment promotion.
Key Concepts¶
Commit Rules & Versioning¶
- Developers must follow a strict commit message format (Conventional Commits).
-
The format determines semantic versioning:
feat:→ minor,fix:/chore:→ patch,BREAKING CHANGE:→ major.
-
Incorrect commit messages are rejected by the server-side hook.
Pipeline Execution (GitLab)¶
- Every merge to
maintriggers a Main pipeline ([DRAFT]). -
The pipeline:
- Calculates a new version based on commit messages
- Builds a Docker image (built once per version)
- Creates an annotated Git tag with that version
- Auto-deploys to the DRAFT environment via ArgoCD (overlay directory
dft/, containerENV=DFT)
Deployment Flow¶
- From DRAFT → manual Deploy DEV button on the Tag pipeline.
-
A Deploy pipeline (
[DEV]) is triggered via API:- Creates a GitLab Release with a generated changelog
- Deploys the same Docker image to DEV
-
Result: DRAFT and DEV run identical versions
Environment Promotion (ArgoCD)¶
-
Promotion is linear and controlled:
DEV → TST → STG → PRD
-
Each promotion:
- Copies
image.tagvalues from one environment overlay to the next - Ensures consistency across environments
- Copies
-
A Git tag and GitLab Release with changelog are created whenever the promotion source is DEV (typically
DEV → TST)
Tracking & Visibility¶
-
GitLab shows:
- Releases with changelogs
- Which versions are deployed where (via deployment tracking)
-
ArgoCD shows:
- Environment states and versions
- Automatic sync after promotion
Rollback Mechanisms¶
Two rollback types are available:
Environment rollback (promotion)¶
- Revert an environment to its pre-promotion state
- Done via the rollback manual button on the promotion pipeline
- Restores previous
image.tagvalues from the saved state file
Version rollback (per environment)¶
- Deploy an older tag to a specific environment (e.g., DEV)
- Navigate to the Tag pipeline for the desired version and click Deploy DEV
- Does not affect other environments
Hotfix Flow¶
- From a Deploy pipeline, click Create Hotfix — a
hotfix/{version}branch is created from the tag - Push fix commits to the hotfix branch — the hotfix branch pipeline builds a new Docker image
- Click Apply Hotfix on the hotfix branch pipeline — the next patch tag (
vX.Y.(Z+1)) is created with an annotatedhotfix ...message - The tag push triggers the hotfix tag pipeline, which creates the GitLab Release and exposes Deploy TEST / STAGE / PROD manual buttons