Skip to content
Vitaliy Zakaznikov edited this page Apr 5, 2025 · 30 revisions
TestFlows Open-source Testing Framework
PyPi: Versions
License: Apache-2.0

Autoscaling Self-Hosted GitHub Actions Runners On Hetzner Cloud

A simple alternative to Github's Recommended autoscaling solutions.

The github-hetzner-runners service program starts and monitors queued-up jobs for GitHub Actions workflows. When a new job is queued up, it creates a new Hetzner Cloud server instance that provides an ephemeral GitHub Actions runner. Each server instance is automatically powered off when the job completes, and then powered off servers are automatically deleted. Both x64 (x86) and arm64 (arm) runners are supported. See Features and Limitations for more details.

TestFlows GitHub Runners
❗Warning: This program is provided on "AS IS" basis without warranties or conditions of any kind. See LICENSE. Use it at your own risk. Manual monitoring is required to make sure server instances are cleaned up properly and costs are kept under control.

Costs depend on the server type, number of jobs, and execution time. For each job, a new server instance is created to avoid any cleanup. Server instances are not shared between jobs.

✋ Note: Currently, Hetzner Cloud server instances are billed on an hourly basis. So a job that takes 1 minute will be billed the same way as for a job that takes 59 minutes. Therefore, unless server reuse is enabled using server recycling, the minimal cost for any job is the cost of the server for one hour plus the cost of one public IPv4 address. If server recycling is used, the amortized cost could be close to per-minute billing depending on server utilization.

Features

  • simpler alternative to what GitHub lists in Recommended Autoscaling Solutions
  • cost-efficient on-demand runners using Hetzner Cloud
  • supports server recycling to minimize costs
  • simple configuration, no Webhooks, no need for AWS lambdas, and no need to setup any GitHub application
  • supports specifying custom runner server types, images, and locations using job labels with fallback options for server types and locations
  • self-contained program that you can use to deploy, redeploy, and manage the service on a cloud instance
  • supports x64 (x86) and ARM64 (arm) runners
  • supports IPv6 only runners
  • supports using any Hetzner Cloud server types
  • supports runners with pre-installed Docker
  • supports using any standard Hetzner Cloud images and applications
  • supports auto-replenishable fixed standby runner pools for jobs to be picked up immediately
  • supports limiting the maximum number of runners created for each workflow run
  • supports efficient GitHub API usage using HTTP caching and conditional requests
  • supports meta labels to keep your job label list short
  • supports estimating the cost of a job, a run, or a set of runs
  • supports prometheus metrics endpoint and embedded dashboard for monitoring
  • supports project configuration files to help manage multiple runner projects

Limitations

Group runners are not supported
✎ However, you can run individual services for each repository using different Hetzner Cloud projects.
A unique Hetzner Cloud project must be used for each repository
✎ However, unique projects allow you to easily keep track of runner costs per repository.

Prerequisites

  • Linux OS (tested on Ubuntu 22.04)
  • Python >= 3.7
  • Hetzner Cloud account
  • GitHub API classic token with privileges to manage self-hosted runners
❗Warning: You must use a classic token. Fine-grained tokens are not supported.

Table of Contents

Clone this wiki locally