05Infrastructure
GitHub Action Runners
The runner is the virtual machine or physical server that executes your code. It's the "Muscle" behind your automation.
Hosted vs Self-Hosted
GitHub-Hosted
Managed by GitHub
Zero maintenance
Fresh machine every run
Pre-installed tools (Node, Docker, etc.)
Free for public repos
No private network access
Limited hardware choice
Usage limits on private repos
Self-Hosted
Managed by YOU
Access private databases/VPNs
Custom hardware (GPU, high RAM)
Total control over environment
No minute limits
You are responsible for security
Requires manual updates
Cost of own infrastructure
The Power of Matrix
Run one job across multiple OS types in parallel.
Job: Test
Click the button above to see the split
Job-by-Job Breakdown
.github/workflows/runners-demo.yml
# Learn - GitHub Action Runners
name: Learn - GitHub Action Runners
on:
workflow_dispatch:
jobs:
# JOB 1: Ubuntu Linux
ubuntu-runner:
name: "GitHub-Hosted: Linux (Ubuntu)"
runs-on: ubuntu-latest
steps:
- name: What OS am I running on?
run: lsb_release -d
- name: What hardware do I have?
run: |
echo "CPU Cores : $(nproc)"
echo "RAM : $(free -h)"
# JOB 2: Windows Runner
windows-runner:
name: "GitHub-Hosted: Windows"
runs-on: windows-latest
steps:
- name: Show Windows info
shell: pwsh
run: Write-Host "OS : $([System.Environment]::OSVersion)"
# JOB 3: macOS Runner
macos-runner:
name: "GitHub-Hosted: macOS"
runs-on: macos-latest
steps:
- name: Show macOS info
run: echo "OS : $(sw_vers -productVersion)"
# JOB 4: Matrix Strategy
matrix-example:
name: "Test on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- run: echo "Running on ${{ matrix.os }}"
# JOB 5: Self-Hosted Runner
self-hosted-reference:
name: "Self-Hosted Runner"
runs-on: self-hosted
if: false
steps:
- run: echo "Running on MY OWN machine!"1
Ubuntu Linux (The Default)
Used 90% of the time. It's fast, lightweight, and comes with almost every dev tool pre-installed.
runs-on: ubuntu-latest
2 & 3
Windows & macOS
Essential for platform-specific builds (like .NET or iOS apps). Note that Windows uses PowerShell (pwsh) as the default shell.
runs-on: windows-latest | macos-latest
4
The Matrix Strategy
Instead of writing 3 jobs, define a matrix. GitHub handles the complexity of spinning up 3 parallel runners for you.
strategy: matrix: os: [...]
5
Self-Hosted (Private Infrastructure)
When runs-on is set to 'self-hosted', GitHub searches for a machine YOU connected to the repository.
runs-on: self-hosted
