Self-hosted runners for PLATE adopters (private repos)
PLATE supports optional ephemeral self-hosted runners so private repositories can run CI on machines you already own when those machines are idle. This guide is general adopter documentation (Epic #1210); project-specific install scripts belong in each adopting repository and are reference implementations only, not requirements of PLATE core.
Related operator docs:
- Actions cost rollout — workflow guards and merged
pr-gatesbefore you add local compute. gh plate runner— CLI entry point; full subcommands (add,status,remove,doctor) land in #1212.
Security warning
Self-hosted runners execute arbitrary code from your repository and from pull requests that can reach those workflows.
| Rule | Why |
|---|---|
| Private repositories only | Never register a self-hosted runner on a public repository. Public repos can receive drive-by PRs; any workflow that uses your runner labels can run untrusted code on your hardware. |
| No fork or outside-contributor PRs on local machines | Workflows triggered by forks or by contributors who are not trusted maintainers must not use self-hosted runner labels. Keep those jobs on GitHub-hosted runners (or disable them) until you have an explicit, reviewed trust model. |
| Non-admin runner OS user | The account that runs the runner service must not be an administrator and must not have access to personal files, SSH keys, browser profiles, or unrelated projects on the host. |
| Secrets per repository | Use repository (or environment) secrets scoped to the private repo that owns the runner. Do not reuse org-wide secrets across untrusted repos. |
| Ephemeral runners | Prefer one job per runner process, then exit. Long-lived runners retain disk state and increase blast radius if a job is compromised. |
| Assume breach | Treat the runner host as periodically untrusted. Patch the OS, rotate registration tokens, and avoid storing long-lived credentials on the runner user profile. |
GitHub postponed its planned per-minute charge for self-hosted runners but did not cancel it. Budget for possible future billing when comparing local vs hosted compute.
GitHub account and runner registration limits
On a personal GitHub account, a self-hosted runner registration is tied to one repository. You cannot share a single registration across multiple repos.
Practical patterns:
- One runner registration per private repo (several repos on the same physical host each get their own registration and token).
- Several runner processes on one host, each registered to the same repo (ephemeral pool).
- A free GitHub organization so org-level runner groups can serve multiple private repos with shared labels and policies (still follow the security rules above).
PLATE does not require a specific hosting vendor; adopters choose machines they control.
Isolation and host setup
Runner user and filesystem
- Create a dedicated OS user (for example
plate-runner) with no admin rights. - Run registration and job checkout only under that user’s home or a dedicated data directory.
- Deny read access to your personal home directory, password stores, and unrelated source trees.
Ephemeral runners
- Register runners as ephemeral when GitHub’s registration API allows it, so the agent exits after one job.
- Use a small idle watcher on each machine (see #1213) to start the next ephemeral runner only when the host is quiet. The watcher must not stop a job that is already running.
Windows: WSL2 with resource caps
On Windows, run Linux jobs inside WSL2, not directly on the desktop session.
- Set CPU and memory limits in
.wslconfigso CI cannot starve interactive work. - Run the runner process at low priority inside WSL2.
- Keep the Windows-side runner user separate from your everyday account.
Linux and containers
Linux runners may use a dedicated VM, a container, or WSL2 on Windows. Containers simplify teardown between jobs but still need a non-root runner user and no mount of sensitive host paths.
macOS
A macOS runner accepts only macOS runs-on labels unless you add Docker or a VM that provides another OS. Workflows that must run on macOS should not rely on Linux-only steps in the same job. Plan separate jobs or use hosted runners for Linux-only gates.
Shared label pool and idle-only policy
Design from #1210:
- Register every machine with a shared label (for example
plate-local) plus an OS label (linux,windows, ormacos). - GitHub schedules each job onto any online, idle runner whose labels match. Machines that are off or busy are skipped.
- Run only when idle: the watcher starts a new ephemeral runner only when CPU load is below a threshold, the machine is on AC power (where applicable), and there has been no recent interactive use. Thresholds and quiet hours are per-machine settings.
- Open question for adopters: how to detect “in use” on each OS without being fooled by background apps (sleep state alone is unreliable on laptops).
No machine needs to be dedicated full-time; local runners are for spare capacity, not a replacement for hosted CI safety gates.
Repository variables (all payload Linux jobs)
Every Linux job in the shipped template payload reads its runs-on from repository variables, defaulting to GitHub-hosted Ubuntu when unset:
runs-on: ${{ (github.event.repository.private != true || (github.event.pull_request && github.event.pull_request.head.repo.full_name != github.repository)) && 'ubuntu-latest' || ((startsWith((vars.CI_RUNS_ON || vars.PLATE_RUNS_ON), '[') || startsWith((vars.CI_RUNS_ON || vars.PLATE_RUNS_ON), '"')) && (fromJSON((vars.CI_RUNS_ON || vars.PLATE_RUNS_ON)) || 'ubuntu-latest')) || (vars.CI_RUNS_ON || vars.PLATE_RUNS_ON) || 'ubuntu-latest' }}
| Variable | Purpose |
|---|---|
CI_RUNS_ON |
Legacy name used by early adopter repos; a single runner label (for example a third-party hosted pool). |
PLATE_RUNS_ON |
PLATE name; same semantics. When both are set, CI_RUNS_ON wins. |
Format: plain labels (e.g. ubicloud-standard-2), JSON strings ("ubuntu-24.04") and JSON arrays (["self-hosted", "plate-local"]) are all accepted; values starting with [ or " are decoded with fromJSON (invalid JSON then fails the workflow instead of queueing); public repositories, fork pull requests and events whose payload does not mark the repository private always use ubuntu-latest, matching plate-select-runs-on; a JSON value that decodes to an empty string also falls back to ubuntu-latest; store values without surrounding whitespace (a leading space defeats JSON detection); probe bootstrap jobs in ci.yml and test-e2e.yml stay on ubuntu-latest.
Force import: gh plate import-payload --strategy force overwrites workflow files from the template. Set CI_RUNS_ON or PLATE_RUNS_ON on the repository so refreshed workflows keep your runner label instead of the default ubuntu-latest.
Heavy workflows (ci.yml, test-e2e.yml) additionally run plate-select-runs-on to probe real self-hosted runners before scheduling test jobs. Labels that name only hosted runners (including ubuntu-latest and ubicloud-*) skip the idle probe.
Fallback to GitHub-hosted runners
When no local runner is free, GitHub queues the job rather than automatically moving it to hosted runners.
PLATE’s workflow integration (#1214) adds a select-runs-on job in heavy workflows (ci.yml, test-e2e.yml) that probes for an online, idle runner with your label and passes runs-on to downstream jobs. The composite action calls GitHub’s List self-hosted runners for a repository API. That endpoint is not available to GITHUB_TOKEN; when the probe cannot authenticate (403, 404, or network error), the action logs a warning and falls back to ubuntu-latest instead of failing the workflow.
The idle-runner probe calls GitHub’s List self-hosted runners for a repository API. GITHUB_TOKEN cannot access that endpoint — workflow permissions do not include repository Administration read, so the default token always fails the probe and PLATE falls back to ubuntu-latest.
To enable local runner selection, store a classic PAT with repo scope or a fine-grained PAT with Administration read on the repository as a secret (for example PLATE_RUNNER_PROBE_PAT), and pass it to the composite action:
- uses: ./.github/actions/plate-select-runs-on
with:
plate-runs-on: ${{ vars.PLATE_RUNS_ON }}
github-token: ${{ secrets.PLATE_RUNNER_PROBE_PAT || github.token }}
All template payload workflows honor CI_RUNS_ON / PLATE_RUNS_ON on lightweight jobs. Template ci.yml and test-e2e.yml wire the probe PAT when present. Without a suitable PAT, self-hosted labels in PLATE_RUNS_ON still queue jobs on GitHub-hosted fallback runners.
Set a job timeout so a queued job eventually runs on GitHub-hosted runners instead of waiting up to GitHub’s default queue horizon (on the order of a day).
Checklist before you register
- Repository is private and will stay private while runners are registered.
- Branch protection and
pr-gatesare configured (actions-cost-rollout). - Fork/outside PR workflows use hosted
runs-ononly. - Dedicated non-admin runner user, ephemeral mode, per-repo secrets.
- Windows jobs use WSL2 with
.wslconfigcaps; macOS jobs use macOS runners only. - Idle watcher and fallback behavior tested on a non-production repo first.