CI vs CD, and what makes a good pipeline
What's the difference between continuous integration, continuous delivery and continuous deployment, and what makes a good pipeline?
TL;DR
Continuous integration (CI): developers merge small changes to the main branch often, and every change is automatically built and tested, so problems surface within minutes. Continuous delivery: every change that passes is always releasable; deploying to production is one click. Continuous deployment: every passing change goes to production automatically, with no human step. A good pipeline is fast, reliable, secure and repeatable: it builds an artifact once, promotes the same artifact through environments, and gives quick, trustworthy feedback.
Key points
- Typical stages: lint and type-check → unit tests → build the artifact (image) → security scans → integration and e2e tests → deploy to staging → deploy to production (progressively).
- Fast feedback: aim for about 10 minutes. Cache dependencies, parallelize tests, and run only affected tests in a monorepo.
- Build once, deploy many: the exact image tested in staging (tagged by commit SHA) is what reaches production. Config comes from the environment.
- Flaky tests destroy trust. Quarantine and fix them; don't add retries blindly.
- Security: short-lived credentials (OIDC from CI to the cloud, not long-lived keys), least-privilege runners, dependency and image scanning, signed artifacts.
- Quality gates: branch protection, required checks, and code review.
- Rollback must be a fast, routine operation.
Example
# GitHub Actions (simplified)
on: [push]
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pnpm install --frozen-lockfile
- run: pnpm lint && pnpm typecheck && pnpm test
- run: docker build -t app:${{ github.sha }} .Common follow-ups
- How do you ship unfinished features with continuous deployment? Feature flags: merge code dark and turn it on separately.
- What DORA metrics matter? Deployment frequency, lead time for changes, change failure rate, and time to restore service.
What interviewers look for
Tip
Define all three precisely, then describe a fast pipeline with build-once promotion, security and rollback.
- Red flag: rebuilding the artifact separately for each environment.