Guideschevron_rightServers

Servers · 7 min read · Updated

How to Set Up a Self-Hosted GitHub Actions Runner

A self-hosted GitHub Actions runner is GitHub's runner program on your own server: it picks up jobs from your repository and runs them there, with your hardware, your cache and your network. To set one up, create a user for it, download the runner from Settings → Actions → Runners → New self-hosted runner, register it with the token GitHub shows, install it as a service and point your workflows at runs-on: self-hosted. Use it with private repositories.

Why Run Your Own

  • Speed: more cores and memory than hosted runners, and caches that stay on disk between builds.
  • Cost: a flat monthly price for the server instead of hosted-runner minutes for heavy pipelines.
  • Access: a fixed IP address for firewalls and allowlists, and private services on the same network.

Our VPS plans start at $37.50 a month, and dedicated servers at $399.00, up to 128 cores in one server.

1. Create a User for the Runner

The runner refuses to register as root. Give it its own user:

sudo useradd -m -s /bin/bash runner
sudo su - runner

2. Download and Register

In GitHub, open the repository (or the organisation, to share runners across repositories), then Settings → Actions → Runners → New self-hosted runner, and choose Linux x64. GitHub shows the commands with the current version and a registration token; they look like this:

mkdir actions-runner && cd actions-runner
curl -o actions-runner-linux-x64-VERSION.tar.gz -L \
  https://github.com/actions/runner/releases/download/vVERSION/actions-runner-linux-x64-VERSION.tar.gz
tar xzf ./actions-runner-linux-x64-VERSION.tar.gz
./config.sh --url https://github.com/OWNER/REPO --token TOKEN --name build-01 --labels linux,x64,vps

Copy the exact lines from GitHub: the version and token change, and the token expires after about an hour.

3. Run It as a Service

Back as a user with sudo, in the runner's folder:

cd /home/runner/actions-runner
sudo ./svc.sh install runner
sudo ./svc.sh start
sudo ./svc.sh status

The runner now starts with the server and shows as Idle under Settings → Actions → Runners.

4. Use It in a Workflow

jobs:
  build:
    runs-on: [self-hosted, linux, x64]
    steps:
      - uses: actions/checkout@v4
      - run: make test

Labels pick the runner: add your own, such as vps or big, to send heavy jobs to a larger server.

5. Install What Your Builds Need

Unlike GitHub's hosted runners, yours starts with only what the operating system has. Install your toolchains once, or run jobs in containers:

curl -fsSL https://get.docker.com | sudo sh
sudo usermod -aG docker runner      # the runner can now start containers
sudo ./svc.sh stop && sudo ./svc.sh start

Membership of the docker group is equivalent to root on that server, which is another reason to keep the runner to repositories you trust. Running Docker on a VPS covers the rest of the setup.

Keeping It Healthy

  • Disk: build caches and Docker images grow. Prune them on a schedule (docker system prune -af --filter until=168h) and watch space as in freeing up disk space.
  • Clean jobs: register with --ephemeral to have a runner take one job and unregister, for builds that must start from a clean state; this needs something to register a new runner each time.
  • Updates: the runner updates itself; keep the operating system patched as on any internet-facing server.
  • Several runners: repeat steps 2 and 3 in folders such as actions-runner-2 with different names, so one server runs several jobs at once.

Common Questions

  • Do self-hosted runners cost less than GitHub's hosted runners?

    Usually, for busy pipelines: jobs on your own runner do not use GitHub's per-minute prices for hosted runners, and you pay a flat monthly price for the server instead. GitHub has changed how it bills self-hosted use before, so check its current Actions billing page for your plan.

  • Is a self-hosted runner safe for a public repository?

    GitHub recommends against it: anyone who opens a pull request from a fork could run code on your server. Use self-hosted runners with private repositories, or require approval before workflows from outside contributors run.

  • How many runners can one server run?

    One runner takes one job at a time. Install several runners, each in its own folder, to run jobs in parallel; a rough start is one runner per four cores, adjusted after watching a few builds.

  • VPS or dedicated server for CI?

    A VPS is plenty for a few builds a day. Builds that run all day, or that compile large projects, finish sooner on a dedicated server, where every core is yours.

Plans and prices

VPS Plans

KVM servers built in minutes: enough for a runner or two, and resized from the dashboard as builds grow.

See all plans
  • Bronze

    3 vCPU · 6 GB RAM · 75 GB NVMe

    2 TB transfer

    $37.50/mo

    Configure inAshburnDallas
  • Silver

    4 vCPU · 8 GB RAM · 100 GB NVMe

    4 TB transfer

    $46.50/mo

    Configure inAshburnDallas
  • Gold

    6 vCPU · 12 GB RAM · 150 GB NVMe

    6 TB transfer

    $60.00/mo

    Configure inAshburnDallas
  • Diamond

    8 vCPU · 16 GB RAM · 200 GB NVMe

    8 TB transfer

    $73.50/mo

    Configure inAshburnDallas

Network port: 10 Gbps in Ashburn, VA, 50 Gbps in Dallas, TX. Pick the location when you configure.

Keep Reading

All guides
Set Up a Self-Hosted GitHub Actions Runner | Virteche Cloud