Lesson 33 gave you the pipeline. Lesson 67 gave you GitLab's version of it. This lesson gives you GitHub's version. GitHub Actions lives where the code lives. A push lands. A workflow file in the repo wakes up. Runners pick up the jobs, actions do the steps, and the result shows up on the same page as the code. I learned GitHub Actions the way I learn most tools in this job. I watched a workflow print a secret into its own logs once, because an action echoed an environment variable nobody had checked, and learned in one afternoon that the runner is a machine that runs code you did not write, with secrets you did write. This lesson walks one workflow run through GitHub Actions, hop by hop, from a first workflow file to the deep end: self-hosted runners, reusable workflows, OIDC, cost, and security.
Difficulty: Advanced · Know this first: Lesson 33, Lesson 67
Every hop charges rent in milliseconds. The bar below is a worked example for one workflow run, not a measurement from a live system, but the shape is honest: in most slow runs I have chased, one or two hops eat almost the whole budget. Step through the lesson or switch the scenario and watch the bar change. The queued run costs almost half as much again as the normal one with the same code. Same jobs, same tests. Only the runner wait changed, and the bill grew by the wait.
The budget bar above shows three fixed stories. This simulator lets you write your own. It models one workflow run with a matrix you size, a cache hit rate you choose, and artifacts you size. Move a slider and watch the total change in the budget bar, in the hop timings, and in the status line. The numbers are a teaching example, not live measurements. The shape is the lesson: the matrix multiplies the cost, the cache saves the setup, and the artifacts are the quiet tax at the end.
The jobs run in parallel, so the wall-clock job time stays 8,000 ms, but each extra job adds 500 ms of spawn and queue overhead.
The setup costs 3,000 ms with a cold cache, and a cache hit saves 2,400 ms. The setup is 3,000 ms minus 2,400 ms times the hit rate.
Uploading costs 12 ms per megabyte.
Try this: (1) Leave the defaults: 3 jobs, 60 percent cache, 50 MB artifacts. The total is about 14,660 ms. (2) Push the matrix to 10 jobs, the cache to 0 percent, and the artifacts to 500 MB. The total is about 25,000 ms. Same code, same tests. Only the knobs changed. (3) Set everything back, then raise the cache hit rate to 100 percent and watch the setup fall to 600 ms. That is what a warm cache buys, and it is the cheapest speed in the pipeline.
Three questions. No score is saved anywhere — this is just you against the material.
GitHub Actions looks like one big tool. It is not. It is four layers stacked on each other, and each layer only makes sense after the one below it. I learned it in this order, and I teach it in this order: run one workflow on a push, then split it into jobs and share it, then protect the secrets and the identity, then run it for a whole company. Skip a layer and the next one reads like magic. Build them in order and nothing in this lesson is magic.
Definition: GitHub Actions at the basic level is a workflow file, a runner, and an event. A workflow is a YAML file in .github/workflows. It says when to run, in the on block, and what to run, in the jobs block. A job is a list of steps, and a step is either a shell command or an action. A runner is the machine that runs the job. You push, the workflow wakes up, the runner picks up the job, and the result shows up on the same page as the code.
Types:
Uses: when a team has a repo on GitHub and wants a build on every push. Build the code, run the tests, and show the result on the pull request. The first win is that the pipeline lives where the code lives, and a green check on the pull request means the same thing to everyone.
Dimensions: Scale: holds up to a few workflows and one team; the runs are short, the runners are hosted, and the minutes are few. Failure modes: a workflow that triggers on every push to every branch burns minutes on branches nobody cares about; an action pinned to a moving tag changes under you without a review. Cost: minutes; public repos are free, private repos get a free allowance, and beyond that you pay per minute. Trade-offs: hosted runners are simple and they are also generic: a fresh machine per job, with no cache and no special hardware. It works until the team needs something the hosted runner does not have.
Definition: structure. A matrix runs the same job with different values, in parallel. Artifacts let jobs share files, because each job runs on a fresh runner. A reusable workflow is a workflow that other workflows call, so the deploy step is written once and used by many repos. Caching saves the dependencies between runs, keyed on the lock file.
Types:
Uses: when the pipeline has to do real work. A matrix across three versions. A build job that uploads an artifact and a deploy job that downloads it. A reusable deploy workflow called by ten repos.
Dimensions: Scale: holds to dozens of workflows and a few teams; the minutes grow with the matrix, and the artifacts grow with the builds. Failure modes: a matrix is a multiplication, so a matrix that grows from 3 jobs to 12 costs four times as much; an artifact uploaded under one name and downloaded under another is a file that does not exist; a reusable workflow that changes breaks every caller at once, so it needs a version. Cost: minutes and storage; the matrix multiplies the minutes, and the artifacts cost storage until they expire. Trade-offs: matrices buy coverage and cost minutes. Reusable workflows buy consistency and cost a blast radius. Caching buys speed and costs a cache that can go stale if the key is wrong.
Definition: control. Self-hosted runners are machines you own, for special hardware, private networks, or cost. Secrets are stored in GitHub and injected as variables, never printed in logs. OIDC replaces stored cloud keys with short-lived tokens minted per run. Environments add approvals and protection rules, so a deploy to production waits for a human.
Types:
Uses: when the team needs something the hosted runners cannot give. A GPU for a build. A runner inside the private network. A deploy that must not use a stored key. A production deploy that must wait for a human.
Dimensions: Scale: holds to hundreds of workflows and many teams; the self-hosted runners need their own maintenance, and the secrets need owners. Failure modes: a self-hosted runner that is offline queues every job that targets it, and a team that notices late has a pipeline that silently waits; a secret printed into a log is a secret that has to be rotated, and the rotation has to reach every place it was used; an OIDC trust policy that names the wrong repo refuses the right one. Cost: maintenance for self-hosted runners, and minutes for hosted ones; a runner you own is a machine you patch, monitor, and pay for. Trade-offs: self-hosted runners buy control and cost uptime: you own the machine, and the machine can be down. OIDC buys security and costs setup: the trust policy has to be right. Environments buy safety and cost a wait: every production deploy waits for a human.
Definition: GitHub Actions as a platform, and an honest comparison with Jenkins. At scale, Actions runs across an org with starter workflows, reusable workflows in a central repo, and policies that limit which actions may run. Cost is a budget line: minutes per repo, per team, per month, with alerts. The comparison with Jenkins is a trade-off, not a loyalty test: Actions wins on zero maintenance and living where the code lives. Jenkins wins on control, on any plugin, and on running anywhere.
Types:
Uses: when Actions runs a whole company. A platform team owns the reusable workflows and the approved action list, and product teams own their workflow files. The cost is watched per team, because a matrix that grows quietly is a bill that grows quietly. And the comparison is used every time a team asks which tool to pick: if the code lives on GitHub and the team wants zero servers, Actions is the simpler answer. If the team needs a pipeline that runs anywhere, on its own machines, with any plugin, Jenkins is still the answer, and Lesson 111 covers it.
Dimensions: Scale: holds at thousands of workflows, because the runners scale on demand and the workflows are split per repo. Failure modes: a central reusable workflow that changes breaks every caller at once, so it needs a version and a test; a minute budget with no alert is a bill that surprises finance; an org policy that blocks an action a team needs will be routed around, and the route around it will be worse than the action. Cost: minutes, storage, and a platform team; the minutes are the bill, and the platform team is the people who watch it. Trade-offs: Actions buys zero maintenance and costs a dependency on GitHub's runners and minutes. Jenkins buys control and costs a controller to run. A central reusable workflow buys consistency and costs a blast radius. There is no free pipeline. There is only a choice about who runs it and what you pay for it.
An action is code you did not write, running on your runner, with your secrets. Pin it to a full commit hash, not to a moving tag. A tag like v1 is a promise that can change. The maintainer can move it, and your pipeline changes without a review. A commit hash cannot move. I pin every third-party action to a hash, and I update the hash on purpose, in a pull request, with a review. The update is a change like any other change, and it gets reviewed like one. The tool that updates hashes automatically is fine, as long as the update still goes through a pull request. A hash that updates itself without a review is a tag with extra steps.
A stored cloud key is a secret that lives forever until someone rotates it, and nobody rotates it. It sits in the repo settings, it gets used by every run, and one day it appears in a log. OIDC fixes this by not having a key at all. GitHub mints a token for the run, the token says which repo and which branch is asking, and the cloud hands back credentials that die when the run ends. The setup is a trust policy on the cloud side, and the trust policy is the part that has to be right: it must name the repo and the branch, and it must limit what the role can do. A trust policy that trusts every repo is a policy that trusts the internet. Write it narrow, and test it with a run from a fork, because a fork is the attacker in this story.
A self-hosted runner is a machine you own, and it runs code from pull requests. Those two facts together are the security story. A pull request from a fork is untrusted code, and untrusted code on your runner can read the files on that runner, including the credentials of the last job. The rules I follow are simple. Never run a pull request from a fork on a runner that holds production credentials. Never let a self-hosted runner keep a workspace between runs unless you clean it. And never put a self-hosted runner on a machine that holds anything else. The runner is a disposable machine, even when it is a physical one. Treat it that way, or it will treat your secrets that way.
A reusable workflow is the shared library of GitHub Actions, and it has the same blast radius. One deploy workflow called by twenty repos is twenty deploys that change when the workflow changes. I version it, I pin the version in each caller, and I test it before it ships. The pin is the safety. A caller that references the main branch is a caller that changes without a review. The same rule holds for composite actions: pin the version, test the change, and roll it out repo by repo, not all at once. A shared workflow that breaks everywhere at once is a shared workflow that was never versioned.
At 10x the workflows, the minutes become a bill worth watching. I track minutes per repo and per team, and I alert when a repo doubles its spend in a week. A matrix that grows quietly is a bill that grows quietly. At 100x, the design changes. The reusable workflows live in a central repo with versions and tests, the starter workflows give every new repo a safe default, and the org policy limits which actions may run. The self-hosted runners scale on demand, and the cost gets a budget line of its own, because at that scale the minutes are a real slice of the platform budget, and a budget nobody watches is a budget nobody controls.
name: build-and-deploy
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node: [18, 20, 22]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3ff414
with:
node-version: ${{ matrix.node }}
cache: npm
- run: npm ci
- run: npm test
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: test-report-${{ matrix.node }}
path: test-report.xml
deploy:
needs: build
runs-on: ubuntu-latest
environment: staging
permissions:
id-token: write
contents: read
steps:
- name: Deploy with OIDC
run: ./deploy.sh staging
One workflow, six ideas. The trigger is narrow: only pushes to main. The matrix runs the same job on three Node versions, in parallel. Every action is pinned to a full commit hash, not to a moving tag, so a tag update cannot change what runs. The setup step caches dependencies by the lock file, so a warm cache skips the download. The test report is uploaded as an artifact, named per matrix value, so each job's proof is saved separately. The deploy job waits for the build job, runs in the staging environment, asks only for the OIDC token permission and read access to the code, and deploys without a stored secret. Read it together and you can see the whole posture: narrow trigger, pinned actions, cached setup, saved proof, and identity instead of keys.
This one stayed with me because the attack did not break into the pipeline. It walked in through an action the pipeline trusted, and the pipeline handed it the secrets.
In March 2025, the GitHub Action tj-actions/changed-files was compromised. An attacker modified the action so that, when workflows ran it, the action printed the workflow's secrets into the build logs, where anyone who could read the logs could take them. The attack worked because the action was widely used and many workflows referenced it by a moving tag, so the bad version flowed into every workflow that used the tag without a review. GitHub removed the compromised versions and the action's maintainer published a fix, but the damage was done the moment the tag moved: thousands of workflows ran the bad code, and every secret those workflows could see was exposed in their logs. The lesson is not that the action was bad. The lesson is that a moving tag is a trust decision, and the decision was made by every workflow that used it.
Three things. First, every third-party action is pinned to a full commit hash now, not to a moving tag. A tag is a promise that can change. A hash cannot move. Second, secrets are scoped to the smallest permission the job needs, and workflows that do not need a secret do not get one. A secret a job cannot see is a secret a compromised action cannot print. Third, logs are reviewed after any action update, and any secret that appears in a log is rotated on the spot. The attack did not break GitHub. It broke the trust model, and the fix was to stop trusting a tag.
Design the GitHub Actions setup for a company with 40 repos, 200 workflows, and a Monday peak of 500 runs. The code lives on GitHub. Some jobs need GPUs, some need the private network, and the rest can run on hosted runners. Deploys to production need a human approval and no stored cloud keys. A bad action update must not break every workflow at once. Sketch the workflows, the runners, the reusable workflows, the secrets, and the cost controls, and say what you would measure.
Start with the budget from this lesson. One run with 3 matrix jobs, a 60 percent cache hit rate, and 50 MB of artifacts takes about 14,660 ms of wall time. The minutes billed are the job time times the jobs: 8,000 ms times 3 jobs is about 0.4 runner-minutes per run. At 500 runs on a Monday peak, that is about 200 runner-minutes, or about 3.3 runner-hours, and that is before the matrix grows. If the matrix grows to 10 jobs, the same 500 runs bill 500 times 10 times 8 seconds, which is about 11 runner-hours. At 500 runs over 8 hours, each spending about 15 seconds in the system, the number inside the system at once is 500 times 15 divided by 28,800, which is less than 1 on average, but the peak is the problem, not the average. The peak is 500 runs in one hour, so I size the self-hosted runner pool for the GPU and private-network jobs, and let the hosted runners absorb the rest. The reusable workflows are pinned at one version per team, so a bad action update breaks one team's workflows, not forty repos.
Hosted runners buy zero maintenance and cost minutes and generic hardware. Self-hosted runners buy control and special hardware and cost uptime and patching. A matrix buys coverage and costs minutes, so I cap the matrix per repo. OIDC buys security and costs setup: the trust policy has to be right. Reusable workflows buy consistency and cost a blast radius, so I pin versions per team. And the target is minutes per team, not wall time. A run that takes 15 seconds and bills 0.4 minutes is cheap. A run that takes 15 seconds and bills 4 minutes, because the matrix is 10 jobs, is a bill that grows quietly.