← All lessons
How CI/CD works
From git push to production
You
Git host
CI runner
Production
.github/workflows/deploy.yml
on: push: branches: [main]jobs: ship: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - run: npm ci - run: npm test - run: npm run build - run: ./deploy.sh dist/runner.js
// what the runner does with the stepsfor (const step of job.steps) { const code = await exec(step); if (code !== 0) { return report("failure"); // the steps after it never run }}report("success");Push a change and see what ships
The diff
Pipeline
Production runsv12 · 7d03be1
Feature branches get tested too. Only main deploys
.github/workflows/ci.yml
on: pushjobs: ship: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - run: npm ci - run: npm test - run: npm run build # only pushes to main deploy - if: github.ref == 'refs/heads/main' run: ./deploy.sh dist/price.test.js
import { total } from "./price.js"; test("adds 11% tax", () => { expect(total(10000)).toBe(11100);});test("rounds half a cent up", () => { expect(total(1050)).toBe(1166);});test("free stays free", () => { expect(total(0)).toBe(0);});Topics
Next: How semantic versioning works
Open lesson