How to Target Jobs With Runner Labels in GitHub Actions
A job runs on any runner that carries every label listed in runs-on, so labels are how you steer jobs to the right hardware.
Add custom labels at registration with --labels, then list them as an array in runs-on. A runner must have all listed labels to be eligible.
Steps
- Register runners with descriptive labels (
gpu,arm64,prod). - List all required labels as an array in
runs-on. - A runner needs every label in the list to match (AND, not OR).
- Add or remove labels later from the runner settings UI.
Register with labels
Terminal
./config.sh --url <url> --token <token> \
--labels self-hosted,linux,gpu,cuda-12Match in a workflow
.github/workflows/ci.yml
jobs:
train:
runs-on: [self-hosted, linux, gpu, cuda-12]
steps:
- run: nvidia-smi && python train.pyGotchas
runs-onlabels are matched with AND; a typo means no runner matches and the job queues forever.- The implicit
self-hosted, OS, and arch labels cannot be removed.
Related guides
How to Set Up Runner Groups in GitHub ActionsOrganize self-hosted GitHub Actions runners into groups to control which repositories and workflows can use t…
How to Register a Self-Hosted Runner in GitHub ActionsRegister a self-hosted GitHub Actions runner by downloading the actions/runner package, running config.sh wit…