Skip to main content

Runner

A CI/CD runner is the machine or container that executes pipeline jobs, either managed by the CI provider or self-hosted on your own infrastructure.

Understanding CI/CD Runners

What Is a Runner and What Types Exist

A runner is the worker that actually runs a job's steps. Hosted runners are ephemeral virtual machines managed by the provider and discarded after each job. Self-hosted runners are machines you run, such as servers, VMs, or Kubernetes pods, that register with the CI platform and pick up queued jobs. Choose self-hosted for private network access, special hardware, or cost at scale.

Hosted vs Self-Hosted

Aspect Hosted Self-hosted
Setup None You install and maintain
State Fresh per job Can persist between jobs
Private network Not reachable Reachable
flowchart LR A[Job queued] --> B{Runner label match?} B -->|Hosted| C[Fresh provider VM] B -->|Self-hosted| D[Your VM or pod] C --> E[Run steps, discard] D --> E classDef q fill:#F97316,color:#FFFFFF classDef r fill:#326CE5,color:#FFFFFF classDef d fill:#10B981,color:#FFFFFF class A,B q class C,D r class E d

Selecting Runners by Label

YAML
jobs:
build:
runs-on: ubuntu-latest # hosted
deploy-prod:
runs-on: [self-hosted, linux, payments-vpc] # your runner in the VPC

Registering a Self-Hosted Runner

Bash
# Download the current runner release from the repo's Settings > Actions > Runners page
mkdir actions-runner && cd actions-runner
# Configure it (token comes from GitHub settings)
./config.sh \
--url https://github.com/razorpay/payment-api \
--token RUNNER_TOKEN \
--labels linux,payments-vpc \
--ephemeral
# Install as a service
sudo ./svc.sh install
sudo ./svc.sh start
# GitLab runner registration
gitlab-runner register --url https://gitlab.com --token REGISTRATION_TOKEN --executor docker --docker-image alpine:latest

The --ephemeral flag makes the runner take one job and then deregister, so each job gets a clean machine. Pair it with autoscaling, for example Actions Runner Controller on Kubernetes.

Troubleshooting

Symptom Check What to look for
Job queued, not starting Runner availability All busy or offline
Runner offline ./svc.sh status Service stopped or token expired
Tool not found Runner image Missing software for this label
Wrong runner picks job Labels Labels do not match exactly
Tip

Label runners by capability, such as arm64 or high-cpu, not by machine name, so you can scale horizontally.

Remember

Hosted runners start clean every time. Install tools per job with setup actions or a container.

Security

Do not attach self-hosted runners to public repositories without strict controls. A malicious pull request can run code on a machine that may hold production credentials.

Common Mistake

Hand-installing tools on a long-lived runner until it becomes a snowflake. Keep runners stateless and reproducible with containers or ephemeral images.

Frequently Asked Questions

When should I use self-hosted runners?

When jobs need private network resources, special hardware such as GPUs or ARM, licensed software, or when hosted minutes become expensive. Otherwise hosted runners are easier and isolated per job.

What security risk is specific to self-hosted runners?

They can persist between jobs and execute code from pull requests, so a malicious PR on a public repository could leave malware or steal secrets. Use them for private repos or require approval for external contributors.

What does an ephemeral runner mean?

It handles a single job and is then destroyed or deregistered, which prevents state leaking from one job to the next.

Found a mistake, an outdated step or a broken link?