Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
Know it before you install
The runner is a small program that connects out to GitHub over HTTPS and asks for jobs. A job runs in the runner's _work folder as the runner's Linux user. You pick the runner in a workflow with runs-on and its labels.
| Item | Value |
|---|---|
| Download | github.com/actions/runner/releases (a .tar.gz for Linux x64 / arm64) |
| Folder | for example /opt/actions-runner/ (owned by the runner user) |
| Scripts | config.sh (register), run.sh (run in the foreground), svc.sh (install as a service) |
| Service | actions.runner.<owner>-<repo>.<name>.service |
| Job folder | /opt/actions-runner/_work/ |
| Logs | /opt/actions-runner/_diag/, journalctl -u actions.runner… |
| Network | outbound HTTPS (443) to github.com and its API and download hosts; no inbound port |
Levels: a runner can belong to one repository, an organization (shared by repos through runner groups) or an enterprise.
Prepare the machine (RHEL and Ubuntu)
Make a user for the runner (never run it as root), and install Git and tools your jobs need:
useradd -m -d /opt/actions-runner -s /bin/bash ghrunner
dnf -y install git tar curl jq
apt-get update && apt-get install -y git tar curl jqIf jobs build containers, install Docker (see the Docker guide). Adding ghrunner to the docker group makes every job root on this host — use such a runner only for trusted repositories.
Download and register the runner
In GitHub open Settings → Actions → Runners → New self-hosted runner (repository or organization), choose Linux. GitHub shows the exact commands with the current version and a registration token (valid one hour). As the runner user:
su - ghrunner
VER=2.329.0
curl -fsSL -o actions-runner.tar.gz https://github.com/actions/runner/releases/download/v$VER/actions-runner-linux-x64-$VER.tar.gz
tar -xzf actions-runner.tar.gz
exit
/opt/actions-runner/bin/installdependencies.sh
su - ghrunner
./config.sh --url https://github.com/ORG/REPO --token AAAAXXXXXXXXXXXXXXXXXXXXXXXXX --name build-01 --labels linux,x64,docker --work _work --unattended
√ Connected to GitHub
√ Runner successfully addedUse the version number GitHub shows on that page. installdependencies.sh installs the .NET libraries the runner needs (run it as root once).
Run it as a service
The service starts at boot and runs as ghrunner:
cd /opt/actions-runner
./svc.sh install ghrunner
./svc.sh start
./svc.sh statusIn GitHub the runner now shows Idle (green).
First configuration: the settings to make first
| What | Why |
|---|---|
| Own user, not root | A job can do everything this user can. config.sh refuses root on purpose. |
Labels (--labels) | Jobs pick the right machine: linux, gpu, prod-deploy … |
| Runner groups (organization) | Only chosen repositories may use this runner. |
--ephemeral for untrusted work | The runner takes one job and then removes itself — no left-overs between jobs. |
| A clean-up job | Delete old Docker images and _work folders (cron with docker system prune -af --filter until=72h). |
| Environment variables | Proxy settings and paths go in /opt/actions-runner/.env (one KEY=value per line). |
Op het werk
For many runners, use Actions Runner Controller (ARC) in Kubernetes: every job gets a fresh runner Pod that disappears after the job.
Use it in a workflow
name: ci
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
jobs:
test:
runs-on: [self-hosted, linux, x64]
steps:
- uses: actions/checkout@v5
- run: make test
deploy:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: [self-hosted, linux, prod-deploy]
environment: production
steps:
- uses: actions/checkout@v5
- run: ./deploy.shA job needs a runner with all the labels in runs-on. The environment: production line lets you require a reviewer before the deploy job starts.
Daily commands on the runner machine:
cd /opt/actions-runner && ./svc.sh status
journalctl -u 'actions.runner.*' -f
ls /opt/actions-runner/_diag/
du -sh /opt/actions-runner/_workReal uses at work:
- Deploy to servers in a private network (no public SSH needed).
- Fast builds with a warm cache, big CPUs, GPUs or ARM machines.
- Run tests that need internal databases or services.
Make it safe
Security checklist:
- Never use self-hosted runners for public repositories: anyone can open a pull request whose workflow runs code on your machine.
- Ephemeral runners (or ARC) for jobs from pull requests; long-lived runners only for trusted branches.
- Runner groups: limit which repositories and workflows may use a runner.
permissions:in every workflow as small as possible; secrets only in environments with reviewers.- Use OIDC to get cloud access (no long-lived keys on the runner).
- No secrets left on disk; separate runners for production deploys.
- Update the runner (it updates itself by default — do not turn that off) and the OS.
Update and remove
Fix common problems
| Problem | Cause | Fix |
|---|---|---|
| Job waits: "Waiting for a runner to pick up this job" | No online runner has all the labels in runs-on. | Compare labels; check the runner is Idle; check the runner group allows the repo. |
Must not run with sudo | config.sh was started as root. | Run it as the runner user. |
Http response code: NotFound from 'POST …' at config | The token expired (1 hour) or the URL is wrong. | Get a new token; use the repo or org URL. |
| Runner shows Offline | Service stopped, or no outbound HTTPS. | ./svc.sh status; curl -I https://api.github.com. |
Got permission denied while trying to connect to the Docker daemon socket | The runner user is not in the docker group. | Add it (root risk!) or use rootless Podman/Buildah. |
| Disk full | Old work folders and images. | Clean _work and Docker; use ephemeral runners. |
| Job fails with "command not found" | The tool is not installed on the runner. | Install it, or use container: / a setup action. |
Next steps
- Quick how-tos: Create a CI pipeline in GitHub Actions, Cache dependencies in CI, Use secrets safely, Build and push an image, CI matrix, Run workflows locally with act, Reusable workflows.
- GitHub Actions step by step: GitHub Actions summary — Choose a runner, Protect self-hosted runners.
- Practise: Lab: build a CI pipeline, Lab: harden a weak workflow.
- From the terminal: Command page: gh. The GitLab version: Install and set up GitLab Runner.
1Why must a self-hosted runner never serve a public repository?
Anyone can open a pull request with a workflow that runs their code on your machine.
2What does --ephemeral do?
The runner takes one job and then removes itself, so nothing is left for the next job.