Skip to content

The self-hosted runner

Most Linux jobs of <owner>/claude run on a self-hosted GitHub Actions runner on the host vps, not on GitHub's ubuntu-latest: every check.yml job, on pull requests, pushes and the nightly run alike, the pages build and claude-review-posted (#895, #994). Each job runs in a fresh container that is thrown away afterwards. The containers run under their own unprivileged user, gh-runner, with a rootless docker daemon. A private GitHub App registers one just-in-time runner per job, and two wait per repository, so two jobs run at the same time. With the runner offline a job waits in the queue; there is no fallback to ubuntu-latest. This page says which runs use it, what a job can reach, how to set it up and how to take it offline.

Which runs use it

A job selects the runner with runs-on: [ self-hosted, vps ]:

Workflow Job Runs on
check.yml validate, version: every event the runner on vps
pages.yml build and gate the runner on vps
pages.yml deploy, on main only ubuntu-latest: GitHub Pages and its environment
claude-review.yml claude-review-posted the runner on vps
claude-review.yml claude-review ubuntu-latest, see below
server-images.yml server images, only on a pull request that changes servers/ ubuntu-latest: the image checks need docker (checks.md)
dashboard-images.yml all ubuntu-latest: builds images with docker

Why the review stays on GitHub. The review's shell commands run in Claude Code's sandbox, which reaches GitHub and no other host (claude-review.yml, #25). The sandbox is bubblewrap, and bubblewrap needs a user namespace. The job container refuses one: it has no capabilities, and Docker's default seccomp profile allows unshare and a namespace clone only with CAP_SYS_ADMIN. It also has no sudo to install bubblewrap. The workflow sets failIfUnavailable, so on the runner the review would stop rather than run without its egress limit. Copilot's review runs on GitHub's side and needs no runner.

The runner serves private repositories only: the supervisor checks each repository before it registers a runner for it, and refuses a public one. A pull request from a fork runs no workflow in this private repository as long as Settings → Actions → Run workflows from fork pull requests stays off; it stays off.

No fallback. With the runner offline, a job waits in the queue and starts when the runner is back. GitHub cancels a job that waits longer than 24 hours. The offline check (below) reports a runner that is offline.

Two at a time. The supervisor keeps two runners waiting per repository (RUNNERS_PER_REPO in its config, set by setup.sh --runners). A third job waits until one of the two is done. One pull request can take both: validate, the pages build when it changes the site, and claude-review-posted each take a runner. The limit is for the host: with two repositories setup.sh keeps one runner for each.

The image before the workflow. A pull request's jobs run its own workflow files on the image the host has now. A workflow change that needs a tool the Dockerfile adds, such as the GitHub CLI for claude-review-posted, fails until setup.sh setup has built the new image on vps. Run it from the owner's clone with the pull request's branch checked out, before that pull request's checks and before it merges.

How a job runs

  1. The supervisor, a systemd user unit of gh-runner, keeps two runners waiting per repository. For each runner it signs a JWT with the App's key, trades it for an installation token limited to that one repository, and asks GitHub for a just-in-time configuration (POST /repos/{owner}/{repo}/actions/runners/generate-jitconfig).
  2. It starts a container of the job image with that configuration in an env file (mode 0600, deleted once the container exists). The runner in the container takes one job.
  3. After the job GitHub removes the runner, the container ends and is deleted (--rm), and the supervisor starts the next one, at most once a minute per repository. A job sees nothing a previous job left behind.

The App's private key lives in Bitwarden Secrets Manager, in its own project gh-runner that only gh-runner's machine account can read; it is not in the dev project that claude syncs. The supervisor fetches it with bws into gh-runner's runtime folder in RAM (/run/user/<uid>, mode 0600); it is never written under /home and never enters a container. When Bitwarden cannot be reached, the copy fetched earlier stays in use. The installation tokens never enter a container either. The supervisor passes every token to curl through a config on stdin, and the machine account's token to bws through its environment, never on a command line.

Piece Where
supervisor scripts/linux/gh-runner/supervisor.sh, installed as /usr/local/lib/gh-runner/supervisor.sh, owned by root
job image scripts/linux/gh-runner/Dockerfile, built as gh-runner-job:<hash of the Dockerfile>
units systemd/gh-runner/: gh-runner.service (the supervisor), gh-runner-check.timer and .service (the offline check)
setup scripts/linux/gh-runner/setup.sh, run as root by the owner
bws /usr/local/lib/gh-runner/bws, pinned by version and SHA-256, owned by root
config and Bitwarden token ~gh-runner/.config/gh-runner/, mode 0700; the machine account's token bws.token, mode 0600
App key the secret GH_RUNNER_APP_KEY in Bitwarden; on the host only in RAM

What a job can reach

A job
runs as the container's user runner, mapped to an unprivileged ID of gh-runner on the host
has git, curl, jq, the GitHub CLI, Python with a virtualenv, Node.js, PowerShell with PSScriptAnalyzer, the runner
has not docker, sudo, any capability (--cap-drop ALL, no-new-privileges), claude's files or tokens, the App's key
sees the secrets its workflow passes, and its own GITHUB_TOKEN
gets at most 6 GB of memory without swap, 2 of the 4 CPUs, 4,096 processes

Memory: vps has 16 GB and no swap, and runs both coordinators and their workers. Two jobs capped at 6 GB each fit beside the coordinators; setup.sh refuses more than two runners on the host, counted over all repositories. Each job container also has a raised OOM score: when memory runs out, the kernel ends a job before a coordinator.

What the isolation does not cover:

  • The network. A job reaches the network as the host does, the tailnet included. A service that listens on the host's Tailscale address answers a job too, behind its own authentication.
  • Who picks the runner. A personal account has no runner groups, so the runner cannot be limited to main or to one workflow. Every ready pull request runs its own code on the runner, and a pull request that changes a workflow can send any job there. CODEOWNERS keeps such a change from merging without the owner, not from running. The container, not the label, is what protects the host.
  • The runner's own credential. The job runs as the same user as the runner and can read the runner's just-in-time credential. It is good for this one runner only, which GitHub removes after the job.

The image

Ubuntu 24.04, pinned by digest, with what validate finds preinstalled on ubuntu-latest. Every download in the Dockerfile is pinned and checked against its SHA-256: the runner (the version the owner chose on #895), PowerShell, Node.js, the GitHub CLI (gh). The image also carries the system libraries and fonts of Playwright's headless Chromium, the install-deps chromium list for Ubuntu 24.04, because a job has no sudo for playwright install --with-deps. It carries no browser binary: a job downloads that itself, as on ubuntu-latest. Three things differ from ubuntu-latest:

  • No docker. The image checks in servers/*/test.sh build and start containers; the image sets CI_NO_DOCKER and they skip with its text as the reason. A pull request that changes a server runs that server's test.sh again on ubuntu-latest, in server-images.yml, which builds the image (checks.md).
  • TruffleHog as a binary. The TruffleHog action runs in a docker container, so both secret scans, a pull request's commits and the whole history, download the pinned binary and check its SHA-256 instead (checks.md).
  • No sudo. A step cannot install a package; what a job needs is in the image.

To update a tool, change its version and checksum in the Dockerfile and run setup.sh setup again. A changed Dockerfile has a new hash, so setup builds a new image and restarts the supervisor on it.

The offline check

gh-runner-check.timer runs supervisor.sh check every 15 minutes. For each repository it asks GitHub, with the App, for the runners labelled vps that are online, and writes one line per repository to /var/tmp/gh-runner-status (mode 0644, no secret in it):

2026-11-22T15:00:00Z <owner>/claude online 2 runner(s), 1 busy

The state is online, offline (no runner online) or unknown (the App's calls failed). When a repository is not online the check unit fails, so systemctl --user --failed of gh-runner shows it as well. bash scripts/linux/status.sh shows the lines as claude, and warns when the last check is more than 30 minutes old.

Set it up

Prerequisites, done on vps once: the user gh-runner with its rootless docker daemon, the cpu, memory and pids cgroup controllers delegated to it, in no docker or sudo group, lingering (the comment on #895).

  1. The GitHub App, in the browser. On the owner's account: Settings → Developer settings → GitHub Apps → New GitHub App. Give it a name and a homepage URL, clear Webhook → Active, and set Repository permissions → Administration to Read and write. Metadata is then Read-only by itself. Under Where can this GitHub App be installed? choose Only on this account. After Create GitHub App, note the App ID and generate a private key.
  2. Install it. In the App's settings: Install App → the owner's account → Only select repositories → the private repositories that use the runner.
  3. The key in Bitwarden, in the browser. In Secrets Manager: a project gh-runner, a secret GH_RUNNER_APP_KEY in it with the whole .pem file as its value, a machine account with Read on that project only, and an access token of that machine account for this host. Delete the downloaded .pem file.
  4. On vps, as the owner's admin account, from the owner's own clone (never from a checkout claude can write):

    sudo bash scripts/linux/gh-runner/setup.sh setup --app-id <App ID> --repo &lt;owner&gt;/claude
    

    It keeps two runners per repository, one each when it serves two repositories; --runners 1 keeps one. It asks for the machine account's access token with hidden input. It checks the user and its daemon, installs the supervisor and bws, checks that bws lists GH_RUNNER_APP_KEY with the token and only then stores it, checks that the key fits the App and that the App is installed on each repository, builds the image (a few minutes the first time) and starts the units. Running it again changes nothing that is already in place. An organization on Bitwarden's US cloud adds --bws-server https://vault.bitwarden.com; the default is the EU cloud.

Check: the repository's Settings → Actions → Runners lists two runners vps-<owner>-claude-<time in microseconds>, idle, with the label vps; sudo bash scripts/linux/gh-runner/setup.sh status shows the units running and the last offline check. Then start a run by hand on main:

gh workflow run check.yml --ref main

Its validate job's log names the runner vps-<owner>-claude-<time in microseconds> under "Set up job".

Take it offline

sudo bash scripts/linux/gh-runner/setup.sh stop

This stops the supervisor and disables it, so it stays stopped after a reboot. On stop, the supervisor stops its containers and removes their runners from GitHub; a job that runs at that moment is cancelled. Every job of the table above that runs on vps then waits in the queue, the required validate of every pull request included. To bring it back:

sudo bash scripts/linux/gh-runner/setup.sh start

To retire the runner for good: change every runs-on: [ self-hosted, vps ] back to ubuntu-latest, then stop, and uninstall the App from the repositories (or delete it).

Rotate the App's key or the token

The App's key: in the App's settings generate a new private key, and put it as the new value of GH_RUNNER_APP_KEY in Bitwarden. Then run setup again:

sudo bash scripts/linux/gh-runner/setup.sh setup --app-id <App ID> --repo <owner>/claude

Its App check fetches the new key and checks it against the App; the running supervisor uses it from then on. Delete the old key in the App's settings afterwards. Without that run, the offline check brings the new key within 15 minutes.

The machine account's token: make a new access token in Bitwarden, then run setup with --new-token and type it in:

sudo bash scripts/linux/gh-runner/setup.sh setup --app-id <App ID> --repo <owner>/claude --new-token

Setup stores the new token only after bws lists the key with it, and restarts the supervisor. Revoke the old token in Bitwarden afterwards.