Workflows, Jobs & Steps
GitHub Actions is GitHub's built-in CI/CD system, and the one most teams meet first. This section teaches it end to end; Release Engineering uses the same syntax for release automation (versions, changelogs, tag-driven releases) and goes deeper into matrices and caching. Workflows can't run on this site (they need GitHub's runners), so the YAML here is non-run, written against the current documentation, and the mechanics behind it run as sessions and models.
The building blocks
| Term | What it is |
|---|---|
| workflow | a YAML file in .github/workflows/; it has a name, triggers (on) and jobs |
| job | runs on one runner (a fresh VM for GitHub-hosted runners); jobs run in parallel unless linked with needs |
| step | runs inside a job, in order: either a shell command (run) or an action (uses) |
| action | reusable step code: actions/checkout@v7 is the repository actions/checkout at tag v7 |
| runner | the machine: ubuntu-24.04, windows-2025, macos-15, ubuntu-24.04-arm, or a self-hosted label |
| expression | ${{ … }}: evaluated by GitHub before the step runs, using contexts (github, env, vars, secrets, needs, matrix, steps, runner, inputs, job) |
A first workflow
# .github/workflows/ci.yml
name: ci
on:
push:
branches: [main]
pull_request:
permissions:
contents: read # least privilege for the automatic GITHUB_TOKEN
env:
PYTHONUNBUFFERED: '1' # workflow-level environment, visible to every step
jobs:
test:
name: Unit tests
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/checkout@v7 # the repository is NOT on the runner until you check it out
- uses: actions/setup-python@v7
with:
python-version: '3.13' # quoted: see "Pipeline as Code"
- name: Install
run: pip install -r requirements.txt
- name: Test
run: |
python -m pytest -q --junitxml=report.xml
- name: Describe the commit
id: describe
run: echo "short=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
- run: echo "Tested ${{ steps.describe.outputs.short }}" >> "$GITHUB_STEP_SUMMARY"Things that surprise newcomers:
- Every job starts on a clean machine. Files from one job are not in the next unless you pass them as artifacts (Job Graphs, Caches & Artifacts).
run:usesbash -eon Linux (preciselybash --noprofile --norc -eo pipefail {0}when you setshell: bash; the default withoutshell:isbash -e {0}, without pipefail). Setdefaults: run: shell: bashat the workflow level to get pipefail everywhere.- Expressions are text substitution.
${{ github.event.pull_request.title }}is pasted into the script before bash sees it; that is the script-injection hole covered in Hardening Workflows. $GITHUB_OUTPUT,$GITHUB_ENV,$GITHUB_PATHand$GITHUB_STEP_SUMMARYare files. A step appends lines; the runner reads them after the step ends.
How step outputs work
The runner gives every step a fresh file in $GITHUB_OUTPUT and parses it after the step: name=value lines, or name<<DELIMITER … DELIMITER blocks for multi-line values. The session imitates a runner executing three steps, so you can see the mechanism without GitHub:
declare -A OUTPUTS
run_step() { # run_step ID SCRIPT: run SCRIPT with its own output file, then parse it like the runner
local id=$1 script=$2 file name value line delim key
while [[ $script =~ \$\{\{\ steps\.([a-z]+)\.outputs\.([a-z]+)\ \}\} ]]; do # expressions first, as text
key="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
script=${script//"${BASH_REMATCH[0]}"/"${OUTPUTS[$key]}"}
done
file=$(mktemp)
GITHUB_OUTPUT=$file bash -eo pipefail -c "$script"
while IFS= read -r line; do
if [[ $line == *'<<'* ]]; then # name<<DELIM ... DELIM
name=${line%%<<*}; delim=${line#*<<}; value=""
while IFS= read -r line && [[ $line != "$delim" ]]; do value+="${value:+