Area 07 · Deployment · Concept 04 of 20

CI/CD Pipelines

Test, build and deploy automatically on every push.

01–10 · The basePhase 5 · Weeks 18–20≈ 1 hour

The idea

Continuous integration runs checks on every change: linting, type checks, unit tests, evals. Continuous delivery or deployment builds an artefact (a container image) and ships it to staging and production automatically when checks pass.

A typical AI pipeline: on pull request, run tests and the CI eval subset; on merge to main, build and push an image tagged with the commit SHA, deploy to staging, run smoke tests, then deploy to production (automatically or after approval).

Pipelines make releases boring and repeatable, and every running version traceable to a commit.

Why it matters

Manual deploys are slow and error-prone. CI/CD is how teams ship many times a day safely.

Picture it

Words to know

  • ArtefactThe built output that gets deployed, like an image.
  • Smoke testA quick check that the deployed app basically works.

Try it without code

Map your pipeline

  1. Write every step you currently do by hand to ship your app.
  2. Mark which ones a machine could do.

Use it in code

The skeleton of a CI/CD workflow (details in the next lessons).

yaml
name: ci-cd
on:
  pull_request:
  push: { branches: [main] }
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: { python-version: "3.12" }
      - run: pip install -r requirements.txt -r requirements-dev.txt
      - run: ruff check . && pytest -q
  deploy:
    if: github.ref == 'refs/heads/main'
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: echo "build image, push, deploy to staging, smoke test, deploy prod"
PRACTICE · TICK IT AFTER THIS

Write down your pipeline stages and add the test job to your repo today.

Common mistakes

  • Pipelines nobody trusts because tests are flaky.
  • Deploying from laptops "just this once".

Go deeper