CI/CD Pipelines
Transformation from manual deployment to continuous automated value delivery. Catch bugs early, deploy fast.
Automatic verification of every commit. We Install, Lint, and Test to ensure the "Continuous" flow doesn't break.
The automatic release of validated code to production. We Build containers and Deploy to staging and production environments.
Pipeline Visualization
Sequential stage execution with dependencies
Push to main triggers build
Wait for Stage 1 to pass
Manual approval for Production
Stage-by-Stage Deep Dive
How to structure your workflow for maximum reliability.
# CI/CD Pipeline
name: CI/CD Pipeline
on:
push:
branches: [main, develop]
workflow_dispatch:
env:
NODE_VERSION: "20"
jobs:
test:
name: "Stage 1 — Install & Test"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- run: npm install
- run: npm test
build:
name: "Stage 2 — Build & Push"
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
push: true
tags: ghcr.io/${{ github.repository }}:latest
deploy-staging:
name: "Stage 3 — Deploy Staging"
needs: build
runs-on: ubuntu-latest
environment:
name: staging
url: https://staging.myapp.com
steps:
- run: echo "Deploying to Staging..."
deploy-production:
name: "Stage 4 — Deploy Production"
needs: deploy-staging
runs-on: ubuntu-latest
environment:
name: production
steps:
- run: echo "Deploying to Production..."The Guardian (Test Stage)
Gatekeeper StageThis job checks the integrity of your code. If one test fails, the entire pipeline stops here. This prevents broken code from ever being packaged.
The Factory (Build Stage)
needs & if guardsOnly runs if tests pass. It packages your app into a Docker Image and pushes it to GHCR. We use 'needs: test' to ensure correct sequence.
The Sandbox (Staging)
Environment VariablesAuto-deploy to a test environment. This is where PMs and QA engineers verify the application before it goes live.
The Real World (Production)
Locked EnvironmentsThe most critical stage. It uses a Production environment with 'Required Reviewers' enabled on GitHub.
The "Production" Guard
By using environment: production, you can enable Required Reviewers in GitHub Settings. The pipeline will physically PAUSE until you click "Approve".
