Git Notes
Runners are the machines that execute your GitHub Actions workflows. When a workflow is triggered, GitHub assigns it to a runner that has the appropriate...
Runners are the machines that execute your GitHub Actions workflows. When a workflow is triggered, GitHub assigns it to a runner that has the appropriate operating system and software. Understanding runners helps you optimize workflow performance, reduce costs, and handle special requirements like GPU computing or custom software installations.
What Is a Runner
A runner is a server — either hosted by GitHub or self-hosted on your own infrastructure — that listens for workflow jobs and executes them. Each job in a workflow runs on a fresh runner instance, ensuring a clean environment without leftover state from previous jobs.
When you write runs-on: ubuntu-latest in your workflow, you are telling GitHub to assign that job to one of their Ubuntu runners.
GitHub-Hosted Runners
GitHub provides managed runners that require zero setup:
jobs:
linux-job:
runs-on: ubuntu-latest # Ubuntu 22.04
windows-job:
runs-on: windows-latest # Windows Server 2022
mac-job:
runs-on: macos-latest # macOS 14 (Sonoma)Available GitHub-Hosted Runner Images
| Label | OS | CPU | RAM | Disk |
|---|---|---|---|---|
| ubuntu-latest | Ubuntu 22.04 | 2 cores | 7 GB | 14 GB |
| ubuntu-24.04 | Ubuntu 24.04 | 2 cores | 7 GB | 14 GB |
| windows-latest | Windows Server 2022 | 2 cores | 7 GB | 14 GB |
| macos-latest | macOS 14 | 3 cores (M1) | 7 GB | 14 GB |
| macos-13 | macOS 13 | 3 cores (Intel) | 14 GB | 14 GB |
Pre-Installed Software
GitHub-hosted runners come with a rich set of pre-installed tools:
- Programming languages (Node.js, Python, Java, Go, Ruby, .NET)
- Package managers (npm, pip, Maven, Gradle)
- Build tools (Make, CMake, Docker)
- Browsers (Chrome, Firefox) for testing
- Cloud CLIs (AWS CLI, Azure CLI, gcloud)
- Database clients (PostgreSQL, MySQL)
Check the full list of installed software in the runner-images repository on GitHub.
Self-Hosted Runners
When GitHub-hosted runners do not meet your needs, you can set up your own:
When to Use Self-Hosted Runners
- You need specific hardware (GPUs, ARM processors, more RAM)
- Your builds require custom software not available on GitHub runners
- You need access to internal network resources (private databases, APIs)
- You want to reduce costs for large-scale builds
- Regulatory requirements demand builds run on specific infrastructure
Setting Up a Self-Hosted Runner
- Go to Repository Settings → Actions → Runners
- Click "New self-hosted runner"
- Follow the installation instructions:
# Download the runner package
mkdir actions-runner && cd actions-runner
curl -o actions-runner-linux-x64.tar.gz -L https://github.com/actions/runner/releases/download/v2.311.0/actions-runner-linux-x64-2.311.0.tar.gz
tar xzf actions-runner-linux-x64.tar.gz
# Configure the runner
./config.sh --url https://github.com/your-org/your-repo --token YOUR_TOKEN
# Start the runner
./run.shUsing Self-Hosted Runners
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- run: npm testAdd labels for more specific targeting:
Runner Groups and Labels
Organize runners with labels for targeted job assignment:
Larger GitHub-Hosted Runners
For compute-intensive jobs, GitHub offers larger runners (paid):
jobs:
heavy-build:
runs-on: ubuntu-latest-16-cores # 16 CPU, 64 GB RAMAvailable sizes range from 4 cores to 64 cores with proportionally more RAM and disk.
Runner Security Considerations
GitHub-Hosted Runner Security
- Each job runs in a fresh VM that is destroyed after the job completes
- No data persists between jobs
- Runners are isolated from other customers
Self-Hosted Runner Security
- Runners persist between jobs (clean up manually)
- Do not use self-hosted runners for public repositories (anyone can trigger workflows via PRs)
- Run the runner service with minimal privileges
- Keep the runner software updated
Optimizing Runner Performance
Caching
- uses: actions/cache@v4
with:
path: node_modules
key: npm-${{ hashFiles('package-lock.json') }}Artifacts for Sharing Between Jobs
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: npm run build
- uses: actions/upload-artifact@v4
with:
name: build
path: dist/
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: build
path: dist/Container Jobs
Run jobs inside Docker containers on runners:
jobs:
test:
runs-on: ubuntu-latest
container:
image: node:20-alpine
env:
NODE_ENV: test
steps:
- uses: actions/checkout@v4
- run: npm ci && npm testThis ensures your job runs in an identical environment regardless of what the runner has installed.
Key Takeaways
Runners are the execution backbone of GitHub Actions. GitHub-hosted runners cover most use cases with zero setup, providing Linux, Windows, and macOS environments with pre-installed tools. Self-hosted runners extend capabilities for custom hardware, network access, or cost optimization. Choose the right runner type for each job — use GitHub-hosted for standard CI work and self-hosted for specialized requirements. Optimize performance with caching, artifacts, and appropriately sized runners to keep your workflows fast and efficient.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for GitHub Actions Runners.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Git & GitHub topic.
Search Terms
git-github, git & github, git, github, actions, runners, github actions runners
Related Git & GitHub Topics