Railway

Deploy Autoscaled Github Actions Runner

Autoscale ephemeral GitHub Actions runners on Railway.

Deploy Autoscaled Github Actions Runner

Just deployed

Just deployed

Deploy and Host Autoscaled Github Actions Runner on Railway

Autoscaled Github Actions Runner is a self-hosted CI runner solution that automatically scales GitHub Actions runner replicas on Railway in response to job demand — adding replicas as jobs queue and resetting back to one once all jobs are complete.

About Hosting Autoscaled Github Actions Runner

Self-hosted GitHub Actions runners on Railway come with a difficult tradeoff. Non-ephemeral runners stay registered and ready for jobs, but remain alive between runs — consuming significant memory on Railway even when idle. Ephemeral runners (--ephemeral) solve the memory problem by exiting cleanly after each job, but they deregister from GitHub on exit, leaving no runner available to pick up the next job without a manual redeploy.

This autoscaler solves both problems. It keeps one replica always running and ready for jobs, listens for GitHub workflow_job webhook events, and calls the Railway GraphQL API to automatically scale up replicas for concurrent workloads and reset back to one replica once all jobs are complete.

Important: Scaling down is intentionally limited. Railway's API can only set a desired replica count — it cannot target a specific replica for removal. Terminating a random replica risks canceling an in-flight job on another runner. To avoid this, the autoscaler only resets replicas once all jobs are complete. This template is not suitable for projects where runners are consistently running many concurrent jobs — replicas will keep scaling up, with many sitting idle, and will never reset back to 1 if jobs are frequently running.

Common Use Cases

  • Teams that want self-hosted GitHub Actions runners without managing their own infrastructure
  • Projects with bursty CI workloads that need parallel runners on demand
  • Teams currently running non-ephemeral runners on Railway who are paying for idle memory between jobs — ephemeral runners exit cleanly after each job, significantly reducing memory costs
  • Teams using ephemeral runners who are frustrated by manual redeployments every time a runner deregisters after a job — this autoscaler detects new jobs via webhook and always keeps a replica ready

Dependencies for Autoscaled Github Actions Runner Hosting

  • A Railway API token with permission to manage services
  • A GitHub Personal Access Token with self-hosted runner permissions (repo Administration or org Self-hosted runners, Read and Write)

Deployment Dependencies

Implementation Details

The autoscaler exposes three endpoints:

  • POST /webhook — receives GitHub workflow_job events, validates HMAC-SHA256 signature, and triggers scaling
  • GET /health — health check used by Railway's healthcheck probe

Scaling logic:

  • First job queued → base replica is already running and picks up the job immediately
  • Concurrent jobs queued → calls serviceInstanceUpdate(numReplicas: N) to add parallel runners
  • Job completed → does nothing mid-batch to avoid canceling in-flight jobs on other replicas
  • All jobs complete → sets replicas to one, or the number of pending jobs

Why Deploy Autoscaled Github Actions 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 Autoscaled Github Actions Runner on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

More templates in this category

View Template
N8N Main + Worker
Deploy and Host N8N with Inactive worker.

jakemerson
View Template
Postgres Backup
Cron-based PostgreSQL backup to bucket storage

Railway Templates
View Template
Prefect [Updated May ’26]
Prefect [May ’26] (ETL & Automation alternative to Airflow) Self Host

shinyduo