GitHub Actions: Self-Hosted Runners
A self-hosted runner is a machine the reader owns that runs GitHub Actions jobs. It replaces the machine GitHub provides with one the reader controls.
Get the runner
The repo settings give the download link and the setup commands. The token is shown once only.
mkdir actions-runner && cd actions-runner
curl -o actions-runner-linux-x64.tar.gz -L <download-link>Connect the runner to the repo
The config command links this machine to the repo. The token proves the machine may join.
./config.sh --url https://github.com/OWNER/REPO --token <token>Start the runner
The run command starts the runner. It waits for a job to arrive.
./run.shExample
name: Self-Hosted Test
on: push
jobs:
test:
runs-on: self-hosted
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '24'
- run: npm testKey points
- Self-hosted runner: the reader's own machine, running jobs for a repo.
- Use a self-hosted runner for special hardware or software GitHub does not provide.
- Download the runner from the repo settings, then run config.sh with the repo address and a token.
- Run run.sh to start the runner and wait for jobs.
- A GitHub-hosted runner is wiped after each job, while a self-hosted runner keeps its state.
- This lesson was not run live in the demo repo, because it needs an owned machine.
In this example, the workflow runs on every push. The job asks for a self-hosted runner instead of ubuntu-latest. The runner checks out the code. It sets up Node 24. It runs npm test. A successful run shows the job on the reader's own machine with a green tick and the test output in the log. This workflow was not run live in the demo repo, because it needs an owned machine.
Note
A self-hosted runner needs the reader's own patching and care, since GitHub does not wipe or update it.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
What does a reader give up by using a self-hosted runner?