CI/CD কী?
- CI — Continuous Integration: merge → build → test automated
- CD — Continuous Delivery: auto deploy to staging
- CD — Continuous Deployment: auto deploy to prod
Pipeline Stages
Code Push ↓ Build (compile, package) ↓ Test (unit, integration) ↓ Code Analysis (SAST, lint) ↓ Artifact (Docker image) ↓ Deploy Staging ↓ E2E Test + DAST ↓ Approval Gate ↓ Deploy Production ↓ Smoke Test + Monitor
GitHub Actions ⭐
# .github/workflows/ci.yml
name: CI
on:
push: { branches: [main] }
pull_request: { branches: [main] }
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm }
- run: npm ci
- run: npm run lint
- run: npm test -- --coverage
- uses: codecov/codecov-action@v4
docker:
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- uses: docker/build-push-action@v5
with:
push: true
tags: myapp:${{ github.sha }}
GitLab CI
# .gitlab-ci.yml
stages: [build, test, deploy]
build:
stage: build
script:
- npm ci
- npm run build
artifacts:
paths: [dist/]
test:
stage: test
script: [npm test]
coverage: '/Lines\s*:\s*(\d+\.?\d*)%/'
deploy:
stage: deploy
only: [main]
script: [./deploy.sh]
environment: production
Other CI/CD Tools
Jenkins (self-host), CircleCI, Travis CI, Azure DevOps, AWS CodePipeline, Bitbucket Pipelines, Drone।
Deployment Strategies ⭐
Recreate (downtime)
Stop old → Deploy new → Start ❌ Downtime
Rolling Update
v1 v1 v1 v1 → v1 v1 v1 v2 → v1 v1 v2 v2 → v1 v2 v2 v2 → v2 v2 v2 v2 ✅ Kubernetes default
Blue-Green ⭐
Blue (live) v1 ← traffic Green v2 (new) ↓ Test Green ↓ Switch LB Green (live) v2 ← traffic Blue v1 (standby for rollback)
Canary ⭐
v1 (95% traffic) → v2 (5%) Monitor errors/latency OK → v1 (90%), v2 (10%) OK → v1 (50%), v2 (50%) OK → v2 (100%) Fail → rollback
A/B Testing
Two versions simultaneously — feature experiment, not just deployment।
Feature Flags
if (featureFlag('new-checkout', user)) {
renderNewCheckout();
} else {
renderOldCheckout();
}
Tools: LaunchDarkly, Unleash, Split.io, Flagsmith।
সুবিধা: deploy ≠ release, gradual rollout, instant kill switch, A/B test, trunk-based dev enables।
Rollback Strategy
- Versioned artifacts (tag, don't delete)
- DB migration reversible
- Feature flag kill switch
- Blue-green instant switch
- Automated on smoke test fail
- Runbook for manual steps
Pipeline Best Practices
- Fast feedback (parallel jobs)
- Fail fast
- Cache dependencies
- Secrets in vault (not code)
- Ephemeral runners
- Infrastructure as Code (Terraform)
- Notify on failure (Slack, email)
- Metrics: lead time, deploy frequency, MTTR, change fail rate (DORA)