Quickstart →

Jobs, steps and needs in GitHub Actions

GitHub Actions jobs run in parallel on separate runners, steps in order on one. How needs chains jobs into stages, and when to use parallel steps instead.

A workflow is made of jobs, and each job is a list of steps. The rules fit in four lines:

  • Jobs run in parallel by default, each on its own fresh runner (a new virtual machine on GitHub-hosted runners, a new container on ubuntu-slim).
  • Steps run one after the other, on the same runner, sharing its filesystem. A failed step stops the job.
  • needs makes a job wait for other jobs, which is how you build stages.
  • Steps can also run in parallel inside a job, with background, wait and parallel (since June 2026).

Jobs#

Each key under jobs: is a job ID. Every job picks a runner with runs-on, except a job that calls a reusable workflow. On GitHub-hosted runners and on ephemeral runners, such as ARC’s or RunsOn’s, each job starts on a clean machine, so files, installed tools and environment variables from one job are not visible in another. A persistent self-hosted runner keeps whatever earlier jobs left behind, which can make builds flaky (prefer ephemeral runners). To hand data over, use job outputs or artifacts (see passing data between jobs).

.github/workflows/ci.yml
name: CI
on:
push:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: npm ci && npm run lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: npm ci && npm test

lint and test start at the same time on two runners. That’s why both repeat the checkout and the install: neither can see what the other did. The cost is extra runner minutes; the benefit is that the slowest job, not the sum of all jobs, sets your wall-clock time.

On GitHub-hosted runners, jobs run in parallel up to your plan’s concurrency limit; extra jobs wait in the queue. For a matrix, strategy.max-parallel sets a lower cap.

Useful job-level keys:

KeyWhat it does
runs-onWhich runner the job uses.
needsJobs that must finish first.
ifSkip the job unless a condition holds.
timeout-minutesCancel the job after N minutes (default 360, the maximum on GitHub-hosted runners).
strategy.matrixRun the same job across several configurations (matrix guide).
environmentDeploy to a protected environment.
concurrencyRun one job at a time per concurrency group. By default, a newer pending job cancels the one already waiting (concurrency guide).
outputsValues other jobs can read through needs.
continue-on-errorDon’t fail the workflow when this job fails.
permissionsSet what the job’s GITHUB_TOKEN can access.
env / defaults.runVariables for every step, and the default shell and working directory of run steps.
services / containerStart service containers for the job, such as a database, or run its steps inside a container.
usesCall a reusable workflow instead of runs-on and steps.

Steps#

A step runs a shell command (run:) or calls an action (uses:). Steps of a job run in order on the same machine, so a file written in one step is there in the next. Since June 2026, a step can also run a group of steps at once (parallel), or wait for or stop background steps (wait, wait-all, cancel): see below.

.github/workflows/ci.yml
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v7
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build
run: npm run build

If a step fails, the job fails and the remaining steps are skipped, unless a status check function in their if: says otherwise. For a step that should still run after a failure, such as a test report or an upload, the usual choice is if: ${{ !cancelled() }}: unlike if: always(), it skips the step when the run is cancelled, so a cancelled run doesn’t wait for it. Use if: failure() for a step that should run only after a failure. Add continue-on-error: true to a step that is allowed to fail, and timeout-minutes to a step that might hang.

A run: step fails when its shell exits with a non-zero code. Without a shell: key, Linux and macOS run the script with bash -e, without pipefail, so npm test | tee test.log passes even when the tests fail: a pipeline returns the exit code of its last command, here tee. Add shell: bash to the step, which also sets -o pipefail, or set it once under defaults.run for the job or the workflow.

Environment variables a step sets with export disappear when the step ends, because each run: is a new shell. Write them to $GITHUB_ENV to keep them for the next steps (see environment variables).

needs: job dependencies#

needs lists the jobs that must finish successfully before this one starts (see GitHub’s needs reference ↗):

.github/workflows/ci.yml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: make build
test-unit:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: make test-unit
test-integration:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: make test-integration
deploy:
needs: [test-unit, test-integration]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: make deploy

This gives a graph: build first, then both test jobs in parallel, then deploy once both pass. Three rules:

  • If any job in needs fails or is skipped, the dependent job is skipped too, unless its if: says otherwise (for example if: ${{ !failure() && !cancelled() }}, explained in conditions).
  • A job reads its dependencies’ outputs and results through the needs context: ${{ needs.build.outputs.version }} for a job output that build declares, and needs.build.result (success, failure, cancelled or skipped) in if: conditions. The context only holds the jobs listed in needs directly, not their own dependencies: list the upstream job too if you need its outputs.
  • needs doesn’t share files: that’s why every job above runs its own checkout. To reuse build’s output instead of rebuilding it, upload it as an artifact in build and download it in the jobs that need it.

Does GitHub Actions have stages?#

No, not as a keyword. GitLab CI and Azure Pipelines have stages:; GitHub Actions has jobs and needs. A “stage” is a group of jobs that need the same upstream jobs, as test-unit and test-integration above. The workflow graph in the Actions tab draws them as columns, which is the closest thing to a stage view.

If you want stages that can be reused across workflows, put each one in a reusable workflow and chain them with needs.

For deployment stages with a manual gate, give each stage its own job with environment: staging or environment: production, chain them with needs, and add required reviewers to the production environment: the production job then waits until a reviewer approves it. In private repositories, required reviewers need GitHub Enterprise (see protection rules).

Running steps in parallel#

Since June 2026, the steps of one job can also run at the same time. background: true starts a step and moves on to the next one, wait blocks until named background steps finish, and parallel runs a group of steps at once and waits for all of them:

.github/workflows/ci.yml
steps:
- uses: actions/checkout@v7
- run: npm ci
- parallel:
- name: Lint
run: npm run lint
- name: Type check
run: npm run typecheck
- name: Unit tests
run: npm test
- name: Build once everything above passed
run: npm run build

Parallel steps share the job’s runner, so you pay for one runner and one setup: choose them over separate jobs when the work needs the same checkout and dependencies, and the runner has the cores to run it all at once. The parallel steps guide has a before/after example and the rules and limits.

Jobs or steps: which one?#

Split into jobs when the pieces need different machines (OS, architecture, size), when you want them to retry independently, or when each one is long enough that parallel runners win back their setup time. Otherwise, keep the work in one job as steps. When those steps could run at the same time, see parallel steps or parallel jobs.

On GitHub-hosted runners, short jobs also cost more than their run time: GitHub rounds each job up to a whole minute, so ten 20-second jobs count as 10 minutes, while the same work as steps of one job counts as 4 at most.