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.

  • 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

  1. Keep the pipeline fast (aim for under 10 minutes for CI).
  2. Build once, deploy the same artifact everywhere.
  3. Store secrets in the CI secret store or a vault – never in YAML.
  4. Protect the main branch: require PR review and passing checks.
  5. Run database migrations as a controlled, backward-compatible step.
  6. Automate rollback and monitor after every deployment.
  7. 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.