Code Reference

Jobs & Steps

GitHub Actions · Reference cheat sheet

Jobs & Steps

GitHub Actions · Reference cheat sheet


📋 Overview

Jobs run in parallel by default on separate runners. Steps within a job run sequentially and share the workspace. Use needs for dependencies, if for conditions, and map outputs between jobs.

🔧 Core concepts

KeyRole
jobs.<id>.runs-onRunner label
needsJob dependencies
ifConditional execution
steps[].usesRun an action
steps[].runShell command
steps[].nameUI label
steps[].idReference outputs
outputsJob-level outputs
continue-on-errorSoft-fail step
timeout-minutesCap duration

Each step can set working-directory, env, and shell. Failures cancel dependent jobs unless configured otherwise.

💡 Examples

Dependent jobs + outputs:

jobs:
  build:
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.meta.outputs.version }}
    steps:
      - uses: actions/checkout@v4
      - id: meta
        run: echo "version=$(node -p 'require("./package.json").version')" >> "$GITHUB_OUTPUT"

  deploy:
    needs: build
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - run: echo "Deploying ${{ needs.build.outputs.version }}"

Multi-line script:

- name: Build
  run: |
    npm ci
    npm run build

⚠️ Pitfalls

  • Jobs don’t share filesystem—pass data via artifacts or outputs.
  • needs + if: always() patterns are easy to get wrong for cleanup jobs.
  • Step outputs must be written to $GITHUB_OUTPUT (not deprecated set-output).
  • Matrix jobs expand into many jobs—watch billing and fail-fast.
  • working-directory doesn’t apply to uses: the same way—check action docs.
  • Shell differences: bash on Linux/macOS, PowerShell default on Windows.

On this page