Workflows
A workflow is a YAML file: events start jobs of steps
on says when. jobs say where. steps say what.
A pipeline in GitHub Actions is a YAML file kept in the repository. Read this one from the top. On lists the events that start it: any pull request, or a push to main. Jobs lists what to run. This workflow has one job, called test, and it runs on a fresh Ubuntu machine provided by GitHub. The steps run in order. Check out the code. Install Python. Install the dependencies. Run the tests. If any step fails, the job fails, and the pull request shows a red cross.
Triggers · Going deeper
Five triggers cover most workflows, and each has its filters
push, pull_request, schedule, workflow_dispatch and workflow_call start most workflows.
CI and CD
CI proves every change; CD ships the artefact that passed
Lint and test, then build once, then deploy the same artefact.
A full pipeline is several jobs wired together. Linting and testing do not depend on each other, so they run in parallel. Only if both pass does the build job run and produce the artefact. That is continuous integration: a verdict on every change, within minutes. After the merge, the same artefact is deployed to staging. A person approves, and the identical artefact goes to production.
Outputs and conditions · Going deeper
A value crosses from step to job through GITHUB_OUTPUT and needs
Write name=value to $GITHUB_OUTPUT, publish it as a job output, read it through needs.
Secrets
A pipeline holds the keys to production: store none in it
Never in the file. A stored secret is acceptable. A per-run token is best.
To deploy, a pipeline needs credentials, and that makes it a target. Written into the workflow file, a key is visible to everyone who can read the repository, and stays in its history. Never do this. A stored secret is encrypted in the settings and handed to the job only while it runs. If it appears in a log, it is masked. Best of all, store nothing. The cloud can be told to trust this repository's pipeline, and issue it a token that expires when the run is over.
Deployment
A canary reaches 1% of users before it reaches everyone
1%, then 10%, then everyone, with a check at every stage.
The riskiest moment is when new code meets real users. A canary release limits the damage. First, one percent of traffic goes to the new version. On the bar, that is the thin purple sliver. The pipeline watches its error rate. If it is healthy, ten percent. Watch again. Then everyone. If anything looks wrong at an early stage, traffic goes back to the old version, which never stopped running.
Deployment · Going deeper
Blue-green and rolling deployment
Blue-green switches all at once. Rolling replaces in batches.
Artefacts
Each job starts clean, so artefacts carry files between
A fresh runner per job. An artefact passes files on.
One fact about pipelines surprises everyone once. The build job runs on its own fresh machine and creates a file. When the job ends, that machine is wiped. So the job uploads the file as an artefact, which is stored alongside the workflow run. The deploy job starts on a different, empty machine. It downloads the artefact, and now it has the file that the build produced.
Artefacts · Going deeper · 1 of 2
Matrices and runners
A matrix multiplies one job across versions and systems.
Limits and defaults · Going deeper · 2 of 2
The limits that end a run, expire a file or evict a cache
A job may run for 6 hours by default. Set timeout-minutes.
Lesson complete
You finished “CI/CD pipelines”
Nicely done.