Build a real CI/CD pipeline with GitHub Actions
Every push to your project lints, tests and builds itself, and only a green build from main ever reaches production. You will write a real workflow for a small app, run the whole thing on your own PC with no GitHub account, watch it go red on a bad change and green on the fix, then add caching, a version matrix and a deploy step that keeps its secrets to itself.
.github/workflows/ci.yml that lints, tests on two Python versions at once, builds a wheel and deploys only from main, with every line explained- Docker installed and working. The whole pipeline runs inside containers. If
docker run hello-worldmeans nothing yet, do Docker without fear first. On Windows, Docker Engine inside WSL2 is the setup used here. - Comfort with a terminal and basic git. You will run a handful of commands and make one deliberate code change. New to git? Git without memorising six commands is enough.
- A little Python. The sample app is a few lines. You do not need to know FastAPI or packaging; if you have done Build your own API or Put a site online for free, you are more than ready.
- About 3GB of free disk. The runner image this mission uses is a 2.3GB download the first time. After that it is cached.
What CI and CD actually buy you
Before any YAML, get the three ideas straight: continuous integration, and the two things CD can mean. The rest of the lesson is one concrete example of each.
A pipeline is a set of checks that run by themselves every time the code changes, on a clean machine that is not yours. Three terms carry most of the meaning:
- CI (continuous integration): on every change, a fresh machine installs the project, runs the linter and the tests, and reports back. It catches the "works on my laptop" bugs, the missing dependency, the test someone broke and did not notice.
- CD, meaning continuous delivery: after CI passes, the pipeline builds a ready-to-ship package (here, a Python wheel) and keeps it, so a release is one button press away. A human still chooses when to ship.
- CD, meaning continuous deployment: the same, but the release happens automatically once the checks pass. No button. This mission builds delivery and shows exactly where the deployment step slots in.
The point of all this is a single rule you can trust: a change only reaches production if the checks are green, and only from the main branch. Everything else in the lesson exists to make that rule real and fast.
You will prove it the honest way, by running the pipeline on this PC with act ↗, a tool that executes GitHub Actions workflows locally in Docker. No account, no pushing, no waiting. The exact same
ci.ymlthen runs unchanged on GitHub.TipGitHub Actions is free for public repositories. Private repositories get a monthly allowance of free minutes, then pay per minute. Running locally with act costs nothing and uses none of that allowance, which is why it is the fastest way to learn.