CI/CD

Let a robot do the deploy at 3am. Robots don’t panic.

▶ the lesson · narrated sketch video · tap for sound

the intro

CI runs your tests automatically on every push. CD takes green code and deploys it. Together they turn deploys from a scary ritual into a non-event: small changes, tested automatically, shipped the same way every time.

fun fact ✦

CI’s first job is emotional: it turns “did I break prod?” into “the robot says no”.

the docs

the deep dive

the ideas behind the video — concepts, diagrams, a walkthrough and the traps to avoid

Humans are wonderful at judgment and terrible at running the same twelve-step checklist identically at 3am. A pipeline is that checklist handed to a robot that never gets tired or cocky. The real payoff is not even the automation — it is feedback speed: you learn in three minutes that a push broke something, not in three weeks when a customer finds it.

small changes, caught small

1git push2tests3build4deploy
each stage hands the work to the next; any failed stage stops the line

key terms

pipeline

The whole checklist a push triggers — install, test, build, deploy — defined as code in the repo itself.

.github/workflows/ci.yml

runner

The disposable machine that executes your pipeline. Ephemeral by design: clean every run, no leftovers.

an ubuntu-latest VM

artifact

The build output a passing stage hands to the next one — a bundle, a Docker image, a dist folder.

dist/ or myapp:sha-abc123

green build

Every stage passed. Main stays green at all times, and only green code earns a deploy.

a red X blocks the merge

how it works

  1. 1
    Push your branch

    The push event is the trigger. The pipeline definition lives in the repo as YAML, versioned right next to the code it guards.

  2. 2
    Runner checks out

    A clean, disposable machine grabs the code and installs dependencies from cache — seconds, not minutes.

  3. 3
    Tests gate everything

    Lint, unit tests, maybe a build. Red stops the line here, so a broken push never gets closer to production than this.

  4. 4
    Build the artifact

    Green code is compiled into exactly one thing — a bundle or image — that every later stage uses, so what you tested is what ships.

  5. 5
    Deploy on green only

    Only a passing main, or a version tag, reaches production. Rollback is just redeploying the previous tag.

the code, explained

a pipeline in eight lines of YAML

1name: CI
2on: [push]
every push and pull request triggers a run
3jobs:
4 test:
5 runs-on: ubuntu-latest
6 steps:
7 - uses: actions/checkout@v4
8 - run: npm ci && npm test
red here blocks the merge, not production

side by side

deploy by hand

  • relies on 3am adrenaline
  • steps live in someone's head
  • skipped step, mystery bug
  • rollback is archaeology
VS

deploy by pipeline

  • same checklist every time
  • every change gets tested
  • red builds never ship
  • rollback is the last tag
🪤 gotcha

A test that fails randomly is worse than no test: people start re-running the pipeline until it is green, and that reflex eventually clicks for the real failures too. Quarantine flaky tests the day they appear and fix them fast — trust in the robot is the whole product.

quick answers

CI versus CD — what is the difference?

CI builds and tests every push. CD deploys whatever passed: continuous delivery stops at a ready artifact waiting for a human, continuous deployment ships it live with no human at all.

How long should a pipeline take?

Under ten minutes is the goal. Past that, people start batching changes, which quietly kills everything CI is for. Cache installs and split jobs to stay fast.

Do I need CI on a solo project?

More than on a team: your future self is the stranger who broke the build, and the pipeline is how past-you leaves a note.

quick hits about CI/CD

short answers · interviews, tips, trivia & hidden gems

🎤 interview

What is CI/CD?watch ↗

📚 tutorial

The four pipeline stageswatch ↗

🔧 useful

Secrets in pipelines?watch ↗

💎 deep

Make pipelines five times fasterwatch ↗

💎 deep

Deploys on green tags onlywatch ↗

🧠 trivia

Why robots deploy at 3amwatch ↗