Overview
Continuous Integration (CI) means every change is merged frequently and automatically built and tested, so problems are caught within minutes. Continuous Delivery (CD) means every change that passes the pipeline is releasable, and Continuous Deployment goes further by deploying it to production automatically.
A typical pipeline runs linting, unit tests, builds, security scans, and container image creation on each pull request, then deploys to staging, runs integration and smoke tests, and promotes to production with a safe strategy (rolling, canary, blue-green) and automatic rollback on failing health metrics.
Each part is checked at every station, not at the end. Defects are caught immediately, and finished cars roll off the line continuously instead of in risky big batches.
When to use it
- Every team shipping software.
- Many developers merging to the same codebase.
- Frequent, low-risk releases.
- Enforcing quality and security gates consistently.
Where it shows up in interviews
Recognize it when: how does code get to production safely?
- Design a deployment pipeline for microservices
- Design CI for a monorepo
Where it is used in real software
Deploys to production many thousands of times per day with automated pipelines and rollbacks.
Common CI/CD platforms; Argo CD and Flux handle GitOps deployments to Kubernetes.
Deployment frequency, lead time, change failure rate, and time to restore measure delivery performance.
Key terms
- CI
- Automatically build and test every change.
- Continuous delivery / deployment
- Always releasable / automatically released.
- Pipeline stage
- Lint, test, build, scan, deploy, verify.
- Artifact
- Built output (image) promoted unchanged across environments.
- Quality gate
- Check that must pass to continue.
How it works, step by step
- 1On pull request
Lint, type-check, unit tests, build.
- 2Security checks
Dependency and image scanning, secret detection.
- 3On merge
Build the image once, tag with commit SHA, push to registry.
- 4Deploy to staging
Integration and smoke tests.
- 5Promote to production
Canary or rolling with automated rollback on SLO breaches.
STEP 1A pull request triggers lint, type-check, and unit tests in parallel.
Pipeline stages and purpose
Typical service pipeline
| Stage | Checks | Fails when |
|---|---|---|
| Static checks | Lint, format, type-check | Style or type errors |
| Tests | Unit, component | Behavior regressions |
| Security | SCA, SAST, image scan, secrets | Critical vulnerabilities |
| Build | Image with SHA tag | Build errors |
| Deploy and verify | Smoke tests, SLO metrics | Errors or latency increase: auto rollback |
NOWStage: Static checks | Checks: Lint, format, type-check | Fails when: Style or type errors
Build once and promote the same artifact; rebuilding per environment breaks the guarantee that what you tested is what you run.
Implementation
name: ci-cdon: pull_request: push: branches: [main] jobs: test: runs-on: bby-ubuntu steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: 22, cache: npm } - run: npm ci - run: npm run lint && npx tsc --noEmit && npm test build-and-deploy: if: github.ref == 'refs/heads/main' needs: test runs-on: bby-ubuntu permissions: { contents: read, id-token: write } steps: - uses: actions/checkout@v4 - uses: bby-corp/tplat-gha-configure-github-credentials@v1 # GIAM credentials - name: Build and push image run: | IMAGE=containers.artifactory.tools.bestbuy.com/team/api:${{ github.sha }} docker build -t "$IMAGE" . docker push "$IMAGE" - name: Deploy (canary) run: kubectl set image deployment/api api=containers.artifactory.tools.bestbuy.com/team/api:${{ github.sha }}Complexity and performance
Fast feedback.
Commit to production (DORA).
Trade-offs
More tests catch more bugs but slow feedback; parallelize, cache, and run slow suites after merge.
Automatic deploys ship faster; approvals add control for regulated systems.
Variants and related techniques
CI updates manifests in Git; Argo CD syncs clusters.
Short-lived branches and feature flags enable continuous integration.
Common mistakes
- Flaky tests.
Fix: Quarantine and fix them; flaky pipelines get ignored.
- Long-lived secrets in CI.
Fix: Use OIDC federation for short-lived cloud credentials.
- Rebuilding artifacts per environment.
Fix: Build once, promote the same image digest.
Interview questions
Describe a CI/CD pipeline for a microservice.
On pull requests: lint, type-check, unit tests, and security scans. On merge: build and scan an image tagged with the commit SHA, deploy to staging with integration tests, then roll out to production via canary with automated rollback based on error rate and latency.
Continuous delivery vs continuous deployment?
Continuous delivery keeps every change releasable, with a human deciding when to release; continuous deployment releases every passing change automatically.
Practice problems
| Problem | Difficulty | What it trains |
|---|---|---|
| Write a CI workflow for a Node service | Easy | Stages and caching. |
| Design CD with canary and auto rollback | Medium | Progressive delivery. |