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

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

GitHub logo

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

ServicePurpose
runnerGitHub'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

VariableDefaultDescription
GITHUB_PATrequiredPersonal access token used to register the runner
GITHUB_SCOPErequiredowner/repository for a repository runner, or owner for an organization
RUNNER_LABELSself-hosted,linux,x64,railwayLabels that runs-on matches
RUNNER_EPHEMERALtrueFresh registration and workspace for every job
RUNNER_GROUP_ID1Runner group; 1 is Default
RUNNER_NAME_PREFIXrailwayPrefix for each replica's runner name
RUNNER_WORK/home/runner/_workJob workspace directory
PORT8080Health endpoint port
RAILWAY_DEPLOYMENT_DRAINING_SECONDS900Time a running job gets to finish on redeploy
RAILWAY_DOCKERFILE_PATHDockerfileDockerfile 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

FeatureRunner on RailwayGitHub-hosted runnersActions Runner ControllerThird-party runner services
HostingYour Railway projectGitHubYour Kubernetes clusterVendor cloud
SetupOne clickNoneKubernetes and HelmInstall an app
Docker in jobs❌✅✅✅
Private network access✅❌✅❌
Auto-scalingManual replicas✅✅✅
PriceAbout $5–20/monthPer-minute after free quotaCluster costPer-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

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.


Template Content

More templates in this category

View Template
Rocky Linux
Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
51
View Template
Foundry Virtual Tabletop
Self-hosted virtual tabletop for role-playing games (license required)

Lucas
71
View Template
NEW
Double Commander in your browser
The Double Commander file manager in the cloud, from any device

Nermin Sabanovic
0