Git & GitHub Interview Question #112

What is a self-hosted runner and when might you use one?

Advanced GitHub Actions, Repository Internals, Submodules, LFS & Diagnostic Tools Senior Advanced

Quick Interview Answer

A self-hosted runner is a machine managed by you or your organization that executes GitHub Actions jobs. It can provide custom hardware, software, network access, or operating-system configuration that hosted runners do not provide.

Detailed Explanation

A self-hosted runner is a machine managed by you or your organization that executes GitHub Actions jobs. It can provide custom hardware, software, network access, or operating-system configuration that hosted runners do not provide.

Self-hosted runners require patching, monitoring, isolation, credential protection, and lifecycle management. Running untrusted pull-request code on privileged self-hosted infrastructure can create serious security risk.

Code Example

jobs:
  internal-build:
    runs-on: [self-hosted, windows, x64]
    steps:
      - uses: actions/checkout@v4
      - run: dotnet build