Stage 5 · Platform
CI/CD Foundations
CI vs CD vs Continuous Deployment
How build verification, release readiness, and automatic production deploys differ in real systems.
Continuous Integration
Continuous Integration (CI) is the practice of merging code changes into a shared repository frequently, with each merge triggering an automated build and test sequence. The goal is to catch integration errors early, before they compound into larger problems.
A CI pipeline typically runs on every pull request and merge to main. It compiles code, runs unit tests, checks formatting, and produces build artifacts. If any step fails, the pipeline stops and developers are notified immediately.
name: CI
on: [push, pull_request]
jobs:
ci:
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
- run: npm run buildThis pipeline validates every push but does not deploy anywhere. It only answers: does this code compile, pass tests, and meet quality standards?
Without CI, you cannot have reliable CD or continuous deployment. CI ensures that every change is verified before it reaches any environment. Teams that skip CI often find their deployment pipelines are unreliable because untested code reaches production.
Continuous Delivery
Continuous Delivery (CD) extends CI by ensuring that code is always in a deployable state. After the CI steps pass, the pipeline produces a release artifact and may deploy it to staging. However, production deployment requires manual approval.
name: CD
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm test && npm run build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
deploy-staging:
needs: build
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/download-artifact@v4
with:
name: dist
- run: ./deploy-staging.sh
deploy-production:
needs: deploy-staging
runs-on: ubuntu-latest
environment:
name: production
url: https://app.example.com
steps:
- uses: actions/download-artifact@v4
with:
name: dist
- run: ./deploy-production.shThe deploy-production job uses a protected environment with required reviewers. Someone must manually approve before production deployment runs.
Continuous Deployment
Continuous Deployment goes further than Continuous Delivery by automatically deploying every change that passes the pipeline to production. There is no manual approval step. This requires high confidence in automated testing, monitoring, and rollback mechanisms.
stages:
- build
- test
- deploy
build:
stage: build
script:
- npm ci && npm run build
artifacts:
paths: [dist/]
test:
stage: test
script:
- npm test
needs: [build]
deploy:
stage: deploy
script:
- ./deploy.sh production
needs: [test]
when: on_success
environment:
name: productionThe deploy job uses when: on_success, meaning it runs automatically after tests pass. No human approval is required.
Comparing the Three
| Aspect | CI | Continuous Delivery | Continuous Deployment |
|---|---|---|---|
| Builds on every push | Yes | Yes | Yes |
| Runs tests automatically | Yes | Yes | Yes |
| Produces deployable artifact | No | Yes | Yes |
| Deploys to staging | No | Yes | Yes |
| Deploys to production | No | Manual approval | Automatic |
| Requires monitoring/rollback | No | Recommended | Essential |
Maturity Model
Most organizations progress through these levels over time. Jumping directly to continuous deployment without solid CI and testing practices leads to frequent production incidents.
- Level 0: Manual builds and deploys — no automation, long release cycles, frequent hotfixes.
- Level 1: CI — automated builds and tests on every push, but manual deployment.
- Level 2: Continuous Delivery — automated artifact creation and staging deploys, manual production approval.
- Level 3: Continuous Deployment — fully automated pipeline from commit to production with monitoring and rollback.
Choosing Your Level
Continuous Delivery is the right default for most teams. It gives you fast, automated validation while keeping a human checkpoint before production. Continuous Deployment is appropriate when you have comprehensive test coverage, reliable monitoring, and fast rollback capabilities.
Continuous deployment without thorough testing is just reckless pushing. The automation replaces human approval with automated quality gates — if those gates are weak, production incidents will follow.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.