GitHub Actions Jobs & Runners
Master GitHub Actions jobs orchestration, GitHub-hosted and self-hosted runners, job dependencies with needs, and inter-job output passing.
GitHub Actions Jobs & Runners
A Job is a distinct set of steps executed inside an isolated virtual machine or container. By default, all jobs in a workflow run in parallel. You can control execution order and build dependency graphs using needs.
1. GitHub-Hosted vs Self-Hosted Runners
GitHub-Hosted Runners
Maintained and updated by GitHub. Fresh virtual machine provisioned for each job execution:
| Label | Operating System | Architecture | Common Use Case |
|---|---|---|---|
ubuntu-latest | Ubuntu Linux (Current LTS) | x86_64 | Standard backend, web apps, Docker builds |
ubuntu-24.04-arm | Ubuntu Linux | ARM64 | Multi-arch image builds |
macos-latest | macOS (Apple Silicon M-series) | ARM64 | iOS / macOS / React Native builds |
windows-latest | Windows Server | x86_64 | .NET, Windows tooling |
jobs:
build:
runs-on: ubuntu-latestSelf-Hosted Runners
Hosted on your own physical or cloud infrastructure (AWS EC2, Hetzner, Bare Metal):
jobs:
gpu-training:
runs-on: [self-hosted, linux, x64, gpu]2. Job Dependency Graph (needs)
By default, jobs execute concurrently. Use needs: to enforce a Directed Acyclic Graph (DAG) sequence:
┌──────────────┐
│ job: test │
└──────┬───────┘
│ (needs: test)
┌──────▼───────┐
│ job: build │
└──────┬───────┘
│ (needs: build)
┌──────▼───────┐
│ job: deploy │
└──────────────┘jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pnpm test
build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pnpm build
deploy:
needs: [test, build]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- run: echo "Deploying to production server..."3. Passing Data Between Jobs (outputs)
Each job runs on an independent runner with an isolated filesystem. To pass strings, IDs, or version numbers between jobs, define job outputs:
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
build_version: ${{ steps.version_step.outputs.version }}
steps:
- id: version_step
run: echo "version=1.4.2" >> "$GITHUB_OUTPUT"
deploy:
needs: prepare
runs-on: ubuntu-latest
steps:
- name: Use output from prepare job
run: echo "Deploying version ${{ needs.prepare.outputs.build_version }}"4. Job Timeouts & Error Control
Always set realistic execution timeouts to prevent hung processes from consuming monthly billable minutes:
jobs:
integration-tests:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Flaky smoke test (does not fail entire pipeline)
run: pnpm test:smoke
continue-on-error: true5. Job Status Functions & Conditions
Control job execution conditionally:
jobs:
notify-slack-on-failure:
needs: [test, build, deploy]
if: failure() # Runs only if any upstream job failed
runs-on: ubuntu-latest
steps:
- name: Send Alert
run: echo "Pipeline failed on branch ${{ github.ref }}"GitHub Actions Events & Workflow Triggers
Comprehensive guide to triggering GitHub Actions workflows with push, pull_request, schedule cron jobs, manual workflow_dispatch, and path filters.
GitHub Actions Steps & Actions
Master steps, shell command execution, marketplace actions, step outputs, GITHUB_ENV, GITHUB_OUTPUT, GITHUB_STEP_SUMMARY, and reusable composite actions.