---
title: "Deploy GitHub Actions Self-Hosted Runner with Auto-Registration"
description: "Run GitHub Actions jobs on your own Railway runner, no token to renew."
category: "Other"
url: https://railway.com/deploy/self-hosted-github-runner
---

# Deploy GitHub Actions Self-Hosted Runner with Auto-Registration

Run GitHub Actions jobs on your own Railway runner, no token to renew.

**[Deploy GitHub Actions Self-Hosted Runner with Auto-Registration on Railway](https://railway.com/template/self-hosted-github-runner)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/self-hosted-github-runner/manifest.json

- **Creator:** blueorange
- **Category:** Other

## Template content

### runner https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/github-light.svg

- **Source:** https://github.com/gridalpha/github-actions-runner-railway

## Documentation

# Deploy and Host a GitHub Actions Self-Hosted Runner on Railway

![GitHub logo](https://github.com/github.png)

GitHub Actions runs your CI and automation workflows, and a **self-hosted runner** lets those jobs execute on compute you control instead of GitHub-hosted machines. This template runs GitHub's official runner, `ghcr.io/actions/actions-runner`, as a Railway service with a small boot script that registers it for you. You paste a personal access token once; the runner then mints a fresh just-in-time registration for every job, so there is no short-lived registration token to copy and nothing expires. The runner is MIT licensed with about 6,400 GitHub stars, and the latest release is 2.338.2. Jobs run in a clean workspace each time, your build caches and dependencies can stay close to your other Railway services, and you can add replicas to run jobs in parallel. GitHub-hosted Linux runners are billed per minute once your free quota is used, roughly $0.008 per minute for a standard runner (approximate). A runner on Railway typically costs about $5–20/month depending on how busy it is.

---

## What This Template Deploys

| Service | Purpose |
|---|---|
| **runner** | GitHub's official Actions runner image plus a boot script, built from the `gridalpha/github-actions-runner-railway` repository. Registers with your repository or organization, takes jobs, and serves a `/healthz` endpoint on port `8080`. No public domain and no volume. |

The health endpoint returns success only while GitHub reports the runner online, so a bad token or a stuck listener fails the deployment instead of staying green.

---

## About Hosting a Self-Hosted Runner

Self-hosted runners are useful when GitHub-hosted minutes get expensive, when jobs need to reach private services, or when you want a fixed machine size for predictable builds.

**No registration tokens to manage.** The runner uses your personal access token to create a just-in-time registration for each job, so redeploys and restarts never need a new token pasted in.

**Ephemeral by default.** Each job gets its own registration and a wiped workspace, which is the setup GitHub recommends for self-hosted runners.

**Repository or organization runners.** Point `GITHUB_SCOPE` at `owner/repository` for one repository, or at `owner` for every repository in an organization.

**Parallel jobs with replicas.** Every replica registers under its own name, so raising the replica count runs more jobs at once.

**Safe redeploys.** A 15-minute draining window lets a running job finish before the old deployment stops.

**Labels for targeting.** Workflows choose the runner with `runs-on` and the labels in `RUNNER_LABELS`, such as `self-hosted` or `railway`.

---

## Deploy a GitHub Runner in Under 5 Minutes

1. Create a personal access token on GitHub. Classic tokens need `repo` scope for a repository runner or `admin:org` for an organization runner. Fine-grained tokens need Administration read and write (repository) or Self-hosted runners read and write (organization).
2. Click **Deploy on Railway** and enter `GITHUB_PAT` and `GITHUB_SCOPE`, for example `my-org/my-repo` or `my-org`.
3. Wait for the health check to pass, then confirm the runner shows as Idle under **Settings, Actions, Runners** on GitHub.
4. Change a workflow job to `runs-on: self-hosted`, or to one of the labels in `RUNNER_LABELS`.
5. Push a commit or trigger the workflow and watch the job run on Railway.

---

## Important: What Does Not Run Here

Railway containers have no Docker daemon and cannot run privileged workloads. Jobs that use the `container:` or `services:` keys, `docker build` or `docker run` steps, kernel modules, nested virtualization or `sudo` beyond the image's own packages will fail on this runner. Ordinary toolchain jobs in Node, Python, Go, Rust, Java and shell run normally, and `actions/cache` works because it stores caches on GitHub.

GitHub advises using self-hosted runners with **private repositories only**. On a public repository, a pull request from a fork can run untrusted code on your runner.

---

## Common Use Cases

- **Cutting CI costs:** move test and build jobs off billed GitHub-hosted minutes.
- **Reaching private services:** run integration tests against databases on Railway's private network.
- **Scheduled automation:** run cron workflows for reports, backups or syncs on your own compute.
- **Organization-wide runner:** share one runner pool across all private repositories.
- **Bigger machines:** give heavy test suites more memory or CPU than a standard hosted runner.
- **Parallel pipelines:** add replicas when a busy repository queues jobs.
- **Deploy jobs:** run release and deploy steps from inside your Railway project.

---

## Configuration

| Variable | Default | Description |
|---|---|---|
| `GITHUB_PAT` | required | Personal access token used to register the runner |
| `GITHUB_SCOPE` | required | `owner/repository` for a repository runner, or `owner` for an organization |
| `RUNNER_LABELS` | `self-hosted,linux,x64,railway` | Labels that `runs-on` matches |
| `RUNNER_EPHEMERAL` | `true` | Fresh registration and workspace for every job |
| `RUNNER_GROUP_ID` | `1` | Runner group; `1` is Default |
| `RUNNER_NAME_PREFIX` | `railway` | Prefix for each replica's runner name |
| `RUNNER_WORK` | `/home/runner/_work` | Job workspace directory |
| `PORT` | `8080` | Health endpoint port |
| `RAILWAY_DEPLOYMENT_DRAINING_SECONDS` | `900` | Time a running job gets to finish on redeploy |
| `RAILWAY_DOCKERFILE_PATH` | `Dockerfile` | Dockerfile used for the build |

**Token security.** The token can register runners, so store it only in Railway, use a fine-grained token limited to the repositories you need, and rotate it if it leaks.

**Long-lived runner.** Set `RUNNER_EPHEMERAL` to `false` to keep one registration and workspace between jobs. It is faster for warm caches but shares state between jobs.

**Extra tools.** The image includes common build tools. For anything else, install it in a workflow step, or fork the repository and add it to the Dockerfile.

**Sizing.** Builds use the service's CPU and memory. Raise them in Railway for large compiles or test suites.

---

## Tips for Fast, Reliable CI

**Cache dependencies.** Use `actions/cache` or the setup actions' built-in caching so each fresh workspace restores packages quickly.

**Use specific labels.** Add a label such as `railway` to the jobs that should run here, and keep other jobs on GitHub-hosted runners.

**Keep secrets in GitHub.** Workflow secrets still come from GitHub, so you do not need to copy them to Railway.

**Watch the queue.** If jobs wait for a runner, add a replica; if the runner sits idle, scale down to save cost.

**Mix runners.** Run Docker-based jobs on GitHub-hosted runners and toolchain jobs here, in the same workflow.

**Set timeouts.** Give long jobs a `timeout-minutes` value so a stuck build does not hold the runner.

---

## Self-Hosted Runner vs. Alternatives

| Feature | Runner on Railway | GitHub-hosted runners | Actions Runner Controller | Third-party runner services |
|---|---|---|---|---|
| Hosting | Your Railway project | GitHub | Your Kubernetes cluster | Vendor cloud |
| Setup | One click | None | Kubernetes and Helm | Install an app |
| Docker in jobs | ❌ | ✅ | ✅ | ✅ |
| Private network access | ✅ | ❌ | ✅ | ❌ |
| Auto-scaling | Manual replicas | ✅ | ✅ | ✅ |
| Price | About $5–20/month | Per-minute after free quota | Cluster cost | Per-minute, often below GitHub |

GitHub-hosted runners need no setup and support Docker. Actions Runner Controller scales on Kubernetes but needs a cluster. This template is the quickest way to get a token-free, self-registering runner next to your Railway services.

---

## Dependencies for GitHub Runner Hosting

- A Railway account.
- A GitHub personal access token with runner registration rights.

### Deployment Dependencies

- [actions/runner on GitHub](https://github.com/actions/runner): the official runner
- [Railway runner build files](https://github.com/gridalpha/github-actions-runner-railway): Dockerfile and boot script
- [GitHub docs on self-hosted runners](https://docs.github.com/actions/hosting-your-own-runners): security and labels

### Implementation Details

The boot script calls GitHub's API to create a just-in-time runner configuration for each job and re-registers inside the container, so ordinary CI traffic never uses Railway's restart budget.

---

## Frequently Asked Questions

**What does this template deploy?**
GitHub's official Actions runner, registered to your repository or organization.

**How much does it cost to host?**
About $5–20/month on Railway, depending on how many jobs it runs.

**Which token do I need?**
A personal access token with `repo` scope for a repository, or `admin:org` for an organization.

**Can my jobs use Docker?**
No. Railway has no Docker daemon, so container jobs and docker steps fail.

**How do I run jobs in parallel?**
Add replicas to the service; each registers as its own runner.

**Is it safe for public repositories?**
GitHub advises self-hosted runners for private repositories only.

---

## Why Deploy and Host a GitHub Runner on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying a GitHub Actions runner on Railway, you get CI jobs on compute you control, next to the services they build and test.


## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — Self-hosted virtual tabletop for role-playing games (license required)
- [Double Commander in your browser](https://railway.com/deploy/double-commander-in-your-browser) — The Double Commander file manager in the cloud, from any device

Open this page in a browser: https://railway.com/deploy/self-hosted-github-runner
