Skip to content

Chapter 4 of 9

Runners: Hosted and Self-hosted

Choose, label, secure, and operate the machines that execute workflow jobs.

36 minutes 10 quick checksBy Subha Prasad
Lesson 4 of 9Course navigation

Lesson content

Read, practise, then check your understanding

Runners: Hosted and Self-hosted

A runner is the compute environment that accepts a job and executes its steps. GitHub-hosted runners offer fresh managed virtual machines and broad toolsets. Self-hosted runners provide custom hardware, network access, or software, but the organization owns patching, isolation, scaling, and incident response.

Core ideas

  • runs-on selects a runner using a hosted image label, custom labels, a group, or a combination.
  • Hosted runners are generally ephemeral; persistent self-hosted machines can retain files and compromised state between jobs.
  • Runner groups restrict which organizations or repositories may schedule work on a pool.
  • Ephemeral autoscaled runners reduce persistence and make clean builds easier to guarantee.

How it works

Match the runner trust level to the code being executed. Pull requests from forks can contain hostile build instructions, so do not route untrusted code to a privileged runner with internal network access. Prefer isolated, short-lived workers with minimal credentials and egress controls.

Configuration example

jobs:
  linux-build:
    runs-on: ubuntu-latest
    steps:
      - run: uname -a

  internal-package:
    runs-on:
      group: production-builders
      labels: [self-hosted, linux, x64]
    steps:
      - run: ./gradlew publish

Read the example from top to bottom: the trigger creates a run, the job requests a runner, and each step receives only the context configured for it. Adapt names, versions, permissions, and commands to the repository rather than copying production credentials or policies blindly.

Production guidance

  • Patch the runner OS, runner application, compilers, and preinstalled tools on a defined schedule.
  • Avoid registering a self-hosted runner at broader scope than necessary.
  • Monitor queue time, disk pressure, job failures, and unexpected outbound connections.

The chapter quiz follows this lesson and checks both the vocabulary and the operational decisions behind the configuration.

Knowledge check

Answer every question correctly to complete this chapter.

Which statement correctly describes GitHub-hosted runner?
Which term matches this explanation: A fresh runner virtual machine managed by GitHub for each job.
Which statement correctly describes self-hosted runner?
Which term matches this explanation: A runner machine managed and secured by the repository owner.
Which statement correctly describes runner label?
Which term matches this explanation: A name used by runs-on to select compatible runner capacity.
Which statement correctly describes ephemeral runner?
Which term matches this explanation: A self-hosted runner registered for only one job, reducing persistence risk.
Which statement correctly describes runner group?
Which term matches this explanation: An access boundary controlling which repositories may use runner pools.

0 of 10 checks passed

Your progress is saved on this device.