iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

CI vs CD vs CD

CI, CD (Continuous Delivery), and CD (Continuous Deployment) are three distinct ideas. Pick the level your team is ready for, and design the pipeline around it.

CI/CD — CI vs CD vs CD

EXAMPLE
# ===== Three letters, three commitments =====
#
# CI  Continuous Integration
#     Every commit on every branch is built and tested automatically.
#     If it goes red, fixing it is the team's top priority.
#
# CD  Continuous Delivery
#     Every successful main build produces a deployable artifact.
#     Deploys are one-click (button or chat command), staged via gates.
#
# CD  Continuous Deployment
#     Every successful main build deploys to production automatically.
#     No human gate after green tests; the safety net is automated rollback.

# ===== Pick the right level =====
# Stage 1 — CI only
#   Tests run on every PR + push. Merging needs green tests.
#   Right when: solo or small team, traditional release cycles, manual deploys.

# Stage 2 — Continuous Delivery
#   Main builds an artifact (Docker image, signed bundle).
#   A deploy script promotes artifacts: dev -> staging -> prod.
#   Right when: you ship weekly+, want auditable deploys, have rollback verified.

# Stage 3 — Continuous Deployment
#   Same pipeline, no manual gate.
#   Right when: high test coverage, fast rollback, feature flags for risky changes,
#   on-call coverage during deploy windows.

# ===== What changes in the YAML at each level =====
# CI:
name: ci
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4 with: { node-version: 20 }
      - run: npm ci
      - run: npm test

# Continuous Delivery (adds build + push + manual deploy):
  build:
    needs: test
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: docker build -t ghcr.io/org/app:${{ github.sha }} .
      - run: docker push  ghcr.io/org/app:${{ github.sha }}
  deploy_staging:
    needs: build
    environment: staging
    runs-on: ubuntu-latest
    steps:
      - run: ./deploy.sh staging ${{ github.sha }}
  deploy_prod:
    needs: deploy_staging
    environment:
      name: production         # requires manual reviewers in repo settings
    runs-on: ubuntu-latest
    steps:
      - run: ./deploy.sh prod ${{ github.sha }}

# Continuous Deployment (removes the manual gate):
  deploy_prod:
    needs: deploy_staging
    runs-on: ubuntu-latest
    steps:
      - run: ./deploy.sh prod ${{ github.sha }}        # auto on green main

# ===== The investments each level needs =====
# CI:    fast tests (<10 min), required status checks on main, branch protection
# CD-1:  build artifacts, environments + secrets, smoke tests post-deploy, rollback runbook
# CD-2:  feature flags, canary / blue-green deploys, automated rollback on SLO breach, on-call

# ===== Patterns to internalise =====
# - You walk the ladder. Skipping straight to Continuous Deployment without flags + rollback ends badly.
# - Promote the SAME artifact through environments; never rebuild for prod.
# - Manual gates exist to absorb risk you have not yet automated away. Replace them with tests over time.
# - The gap between 'green tests' and 'safe to deploy' is closed by feature flags and observability.

# ===== Pitfalls =====
# - Calling deploy-from-CI 'CI/CD' but rebuilding the image at each stage -> non-reproducible
# - 'CD' meaning Continuous Deployment in one room, Continuous Delivery in another -> say which
# - Skipping post-deploy verification because tests are green -> drift between staging and prod surfaces here
# - Pipelines longer than 30 min -> people batch commits to avoid the wait, defeating CI

Why it matters

CI, Continuous Delivery, Continuous Deployment are three commitments — pick the one your safety net actually supports. Walk up the ladder by paying down the investments each level demands: fast tests, reproducible artifacts, smoke tests, feature flags, automated rollback. Skipping rungs is how outages happen.

Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.

Example

Example
# CI: merge code often; verify with tests + lints.
# CDelivery: every green build is releasable.
# CDeployment: every green build is auto-released.
Try it Yourself »

Discussion

Loading…