Running CI on Your Own Hardware
Last reviewed September 9, 2026.
An agent fleet opens and updates pull requests around the clock. Every push starts a CI run, and on GitHub-hosted runners every run bills minutes. One CPLai fleet produced about 1,000 runs in sixteen days on a private repository, at roughly $0.60 each. Self-hosted runners on hardware you already own bill nothing, and on a modern workstation or a DGX-class box they finish a run in a fraction of the time. This page explains when that is worth doing and how to set it up. CPLai does not manage runners for you today; the setup happens in your GitHub repository and on the machine that will run the jobs.
When is this worth doing?
- You run agents that open or update pull requests on a private repository, and the repository has a CI workflow.
- Your GitHub Actions bill or minute usage is rising with agent activity rather than with your own work.
- You have a machine that is on most of the day with spare CPU, memory, and disk: a workstation, a home server, or a GPU box that also hosts local models.
If your repositories are public, GitHub-hosted minutes are free and this page does not apply. If a repository sees a handful of runs a month, the setup is not worth the maintenance.
How do the pieces fit together?
| Piece | Where it lives | What it does |
|---|---|---|
| Runner | A directory and a service on your machine | Polls GitHub for jobs, runs them, reports results |
| Labels | Set when you register the runner | The name your workflow asks for in runs-on |
| Repository variables | GitHub repository settings | Let you switch between your runners and GitHub's without editing the workflow |
| Persistent caches | Directories on the runner machine | Keep compiled dependencies and package caches between runs, which is where most of the speed comes from |
| Resource guards | Service configuration on the runner machine | Cap memory and wait for free memory so a CI job cannot starve other workloads on the same box |
How do I register a runner?
Runners belong to one repository unless your repositories live in a GitHub organization. A personal account registers one runner directory per repository; an organization can share one pool of runners across every repository through a runner group.
- In the repository, open Settings -> Actions -> Runners -> New self-hosted runner and pick the operating system and architecture of the machine.
- Follow the download and configure commands shown there. During configuration, give the runner a label you will use in your workflow, for example
my-linuxormy-windows. - Install it as a service so it survives reboots. On Linux the runner ships
svc.sh installandsvc.sh start; on Windows re-run the configure step from an elevated prompt with--runasservice. - Confirm the runner shows Idle in the repository's Runners page.
Register one runner directory per parallel job you want the machine to run. Two runner services on one box run two jobs at once.
How do I point a workflow at my runners?
Create two repository variables, for example CI_LINUX_RUNNER set to my-linux and, if you have a Windows job, CI_WINDOWS_RUNNER set to my-windows. Then change each job's runs-on to read the variable with a fallback:
runs-on: ${{ vars.CI_LINUX_RUNNER || 'ubuntu-latest' }}
Setting the variable back to ubuntu-latest (or windows-latest) returns that repository to GitHub-hosted runners instantly, with no workflow change. That is your safety net while the runner machine is down.
Keep job names unchanged if they are required status checks in branch protection; the runner is invisible to the checks.
What has to change inside the workflow?
GitHub-hosted runners start from a fresh virtual machine each time. Your machine does not, and it is shared. Walk through every workflow with this list:
| Situation | Change |
|---|---|
Steps that run sudo or apt-get |
Gate them with if: runner.environment == 'github-hosted' and install the packages once on your machine |
actions/cache and setup-node package caches |
Gate them the same way; your machine keeps its own package caches between runs |
| Compiled languages (Rust, Go, .NET) | Point the build output at a persistent directory on the runner machine, for example an environment variable set in the runner's .env file, so the second run is incremental |
| Service containers (Postgres, Redis, search engines) | Publish random host ports (ports: - 5432) and read the assigned port from job.services.<name>.ports['5432']; a fixed port collides with the host's own services and with a second runner |
| Actions that write to a fixed temporary path | Set TMPDIR: ${{ runner.temp }} on the step; two runners on one host share /tmp |
| Windows jobs | Put shell: bash on run steps; a runner service account usually has a restricted PowerShell execution policy, and make sure Git Bash is ahead of any other bash.exe on the runner's PATH |
| Docker builds and Compose stacks | Name images and containers per run (${{ github.run_id }}), tear them down in an if: always() step, and prune old images on a schedule |
| Tools the hosted image provided for free | Install them once on your machine: PowerShell, language runtimes, browser dependencies for end-to-end tests |
A job that finishes in thirty seconds after every step was skipped is not a migration. Open the log and confirm the tests actually ran.
How do I keep CI from disturbing other work on the machine?
Treat the runner like any other tenant of the box.
- Cap its memory. On Linux, give the runner's systemd service a
MemoryMax(for example 40 GB on a 121 GB machine) and disable swap for it. A compile that exceeds the cap is killed instead of stalling everything else. - Wait for free memory before starting a job. The runner supports a job-started hook (
ACTIONS_RUNNER_HOOK_JOB_STARTEDin its.envfile). A short script that pollsMemAvailableand refuses to start below a floor keeps CI from colliding with a large local model that happens to be resident. This matters on machines with unified memory, where a GPU model and a compiler draw from the same pool. - Bound concurrency. The number of runner services is the number of simultaneous jobs. Start with two and add more only when jobs queue.
- Keep the workflow's cancel-in-progress setting. Superseded pushes should stop the older run so the queue stays short.
What does a typical result look like?
Measured on one CPLai repository on the day of the move, comparing GitHub's standard runners with a 20-core workstation and a DGX-class Linux box:
| Job | GitHub-hosted | Own hardware |
|---|---|---|
| Rust type check (Windows) | 19 minutes, up to 45 cold | under a minute warm |
| Rust test suite, 4,000+ tests | 25 minutes | 3 to 5 minutes |
| TypeScript tests, 5,000+ tests | 13 minutes | 2 to 3 minutes |
Faster runs also surface test-isolation bugs that slow runners hid, such as tests that assume a fixed database name, a fixed HOME, or an exact row count while another test runs. Treat those as real bugs to fix, not as runner flakiness.
Current boundaries
- CPLai does not provision, monitor, or cap runners for you. Everything on this page happens in GitHub and on the runner machine.
- Sharing one runner pool across repositories requires a GitHub organization; personal accounts register runners per repository.
- Self-hosted runners execute whatever a workflow asks. Do not attach them to public repositories that accept pull requests from strangers.
Related pages
- Development Workspaces for review and CI checkpoints inside CPLai
- Docker Environments for running containers on a remote Docker host
- Usage, Costs, ROI, and AI Insights for the spend CPLai does track
- Local Models if the runner machine also serves models