All Modules What CI/CD Is GitHub Actions Continuous Delivery The Merge Gate عربي

CI/CD Pipeline

Test, gate, and build on autopilot — every push checked automatically, before it can break anything.

Module 9 · GitHub Actions, bridging into the DevOps Lab.

Intermediate CI/CD Includes Lab ~50 min

What You'll Learn

  • What Continuous Integration and Continuous Delivery actually mean
  • Write a GitHub Actions workflow that runs on every push
  • Run your lint, tests, and build automatically — the gates from Modules 6–7, now enforced
  • Build the Docker image in CI so it's always deploy-ready
  • Hands-on lab: push to GitHub and watch your pipeline go green

Prerequisites: Module 8, a free GitHub account. Deep dive: DevOps Lab: CI/CD.

What CI/CD Really Is

You've been running lint, tests, and builds by hand. A pipeline runs them for you, automatically, on a clean machine, every time you push. That's the difference between "I remembered to check" and "it's impossible to merge broken code."

TermPlain meaning
CI (Continuous Integration)Every push is automatically linted, tested, and built.
CD (Continuous Delivery)Passing builds are automatically packaged — and, optionally, deployed.
WorkflowThe YAML file describing the steps to run.
RunnerThe clean machine GitHub spins up to run your workflow.

Why it's the perfect fit for AI code

An AI can introduce a subtle break at any moment. CI catches it on the very next push, on a machine that isn't "your machine" — so "works for me" never reaches anyone else.

A GitHub Actions Workflow

A workflow is one YAML file in .github/workflows/. This runs your gates on every push:

# .github/workflows/ci.yml name: CI on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: 20 } - run: npm ci - run: npm run lint - run: npm test - run: npm run build

Same file you'll see in the DevOps Lab

The DevOps Lab CI/CD module and its sample-app/.github/workflows/ci.yml use exactly this pattern, extended with a Docker build-and-push. Have the assistant draft yours — then read it, because a workflow is code too.

From Integration to Delivery

Once CI is green, CD takes the next step: build the container image from Module 8 and publish it to a registry, so a deployable artifact exists for every passing commit. Full auto-deploy comes in Module 10 — here we make sure the image is always built and ready.

# extra CD step: build + push the image on main - run: docker build -t ghcr.io/OWNER/snippet-vault-api ./api - run: docker push ghcr.io/OWNER/snippet-vault-api

Make CI a Required Gate

The payoff: turn on branch protection so a pull request can't merge into main unless CI passes. Now the gates from Modules 6–7 aren't a suggestion — they're enforced by the platform, for you and any future collaborator (human or AI).

The loop closes

Spec → build with the loop → tests → gates → CI enforces them on every push. Broken or unsafe code physically can't reach your main branch. That's the professional standard, running itself.

Practical Lab: Your Pipeline Goes Green

You'll push the vault to GitHub, add a CI workflow that runs your gates on every push, and watch it pass — then prove it blocks a break.

What you need

Your containerized snippet-vault from Module 8 and a free GitHub account.

1

Push to GitHub

Create a new repo on GitHub, then:

git remote add origin https://github.com/YOU/snippet-vault.git git push -u origin main
2

Add the CI workflow

Create .github/workflows/ci.yml that, on push and pull_request, runs npm ci, npm run lint, npm test, and npm run build for the api. Use Node 20.

Review it, commit, and push.

3

Watch it run

Open the Actions tab on GitHub. Your workflow runs on the clean runner — watch lint, test, and build go green.

4

Prove the gate blocks a break

On a branch, deliberately break a test, push, and open a pull request. CI should go red and block the merge. Fix it, push again, watch it turn green. Then add a CI status badge to your README.md.

5

Reflect

In REFLECTION.md: what did CI catch that you might have merged locally? Commit and push.

What to hand in

Your GitHub repo URL. Self-check:

  • The repo is on GitHub with a green CI run
  • ci.yml runs lint, tests, and build on every push
  • You saw CI go red on a broken commit and block the PR
  • A CI badge in the README; REFLECTION.md updated

Mini Glossary

TermPlain meaning
PipelineThe automated sequence of checks/builds a push goes through.
WorkflowThe YAML file defining that sequence (GitHub Actions).
RunnerThe fresh machine that executes the workflow.
Branch protectionA rule that blocks merges unless checks pass.
RegistryWhere built container images are stored (e.g. GHCR).

Recap & What's Next

You now have

A CI pipeline that runs your gates on every push, blocks broken code from merging, and builds a deployable image — your engineering standards, enforced automatically.

Next up: Module 10 — Deploy + Infrastructure as Code. We take that built image live, and define the infrastructure it runs on as version-controlled code — reproducible deployments, no clicking around.

CI/CD Pipeline

Objectives What CI/CD Is GitHub Actions Continuous Delivery The Merge Gate Practical Lab Glossary Recap