Quick answer: CI (Continuous Integration) automatically builds and tests every code change when it is pushed. CD means either Continuous Delivery (every passing change is ready to release with one click) or Continuous Deployment (every passing change goes to production automatically). A typical pipeline: checkout β install β lint β test β build artifact/image β security scan β deploy to staging β approval β deploy to production β monitor.
Why CI/CD matters
- Bugs are caught minutes after they're written, not weeks later.
- Releases become small, frequent and boring β which means safe.
- No more "works on my machine": the pipeline is the source of truth.
- It's a must-have skill in almost every developer and DevOps job description.
Pipeline stages
Stage | What happens | Fails when |
|---|---|---|
Trigger | Push or pull request | β |
Build | Restore dependencies, compile | Compile errors |
Lint / format | Code style and static analysis | Style violations, code smells |
Test | Unit, then integration tests | Any test fails, coverage below threshold |
Security | Dependency and secret scanning, SAST | Critical vulnerabilities |
Package | Build Docker image or artifact, tag with commit SHA | Build errors |
Deploy staging | Automatic | Smoke tests fail |
Deploy production | Manual approval or automatic | Health checks fail β rollback |
Example: GitHub Actions pipeline
name: ci-cd
on:
push:
branches: [ main ]
pull_request:
jobs:
build-test:
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
- run: npm run build
deploy:
needs: build-test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment: production # can require manual approval
steps:
- uses: actions/checkout@v4
- run: ./scripts/deploy.sh
env:
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}Action versions change over time β always check the latest major version in each action's repository.
Popular CI/CD tools
- GitHub Actions β built into GitHub, YAML workflows.
- GitLab CI/CD β
.gitlab-ci.yml, strong self-hosted option. - Azure DevOps Pipelines β common in Microsoft/.NET enterprises.
- Jenkins β open-source, highly customisable, older but widespread.
- Argo CD / Flux β GitOps deployment to Kubernetes.
Deployment strategies
- Rolling: replace instances gradually.
- Blue-green: run two environments; switch traffic at once; instant rollback.
- Canary: send a small percentage of traffic to the new version first.
- Feature flags: deploy code dark, enable features independently of releases.
Best practices
- Keep the pipeline fast (aim for under 10 minutes for CI).
- Build once, deploy the same artifact everywhere.
- Store secrets in the CI secret store or a vault β never in YAML.
- Protect the main branch: require PR review and passing checks.
- Run database migrations as a controlled, backward-compatible step.
- Automate rollback and monitor after every deployment.
- Use infrastructure as code (Terraform, Bicep, CloudFormation).
Key DevOps metrics (DORA)
- Deployment frequency
- Lead time for changes
- Change failure rate
- Time to restore service
Summary
- CI = build and test every change automatically.
- CD = always releasable (delivery) or auto-released (deployment).
- Lint, test, scan, package, deploy, monitor.
- Build once, protect secrets, keep it fast, and plan for rollback.