.. image:: https://raw.githubusercontent.com/testflows/TestFlows-ArtWork/master/images/logo_small.png :align: right :target: https://testflows.com :alt: TestFlows Open-source Testing Framework
.. image:: https://img.shields.io/github/v/release/testflows/TestFlows-GitHub-Hetzner-Runners :target: https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/releases :alt: Latest Release
.. image:: https://img.shields.io/github/contributors/testflows/TestFlows-GitHub-Hetzner-Runners :target: https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/graphs/contributors :alt: Contributors
.. image:: https://img.shields.io/github/issues/testflows/TestFlows-GitHub-Hetzner-Runners :target: https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/issues :alt: Open Issues
.. image:: https://img.shields.io/github/stars/testflows/TestFlows-GitHub-Hetzner-Runners?style=plastic :target: https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/stargazers :alt: GitHub stars
:PyPi:
Versions <https://pypi.org/project/testflows.github.hetzner.runners/>
:License:
Apache-2.0 <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/blob/main/LICENSE>
A simple alternative to Github's Recommended autoscaling solutions <https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/autoscaling-with-self-hosted-runners#recommended-autoscaling-solutions>
_.
:🔍 Tip:
See Wiki <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki>
_ for full documentation.
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.
.. image:: https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/blob/main/docs/images/github_runners.gif :align: center :alt: TestFlows GitHub Runners in Action
:❗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, the minimal cost for any job, the cost of the server for 1 hour plus the cost of one public IPv4 address.
Recommended Autoscaling Solutions <https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/autoscaling-with-self-hosted-runners#recommended-autoscaling-solutions>
_Hetzner Cloud <https://www.hetzner.com/cloud>
_Home <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki>
_Installation <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Installation>
_Quick Start <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Quick-Start>
_Getting Started Tutorial <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Getting-Started-Tutorial>
_Basic Configuration <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Basic-Configuration>
_Specifying the Maximum Number of Runners <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Specifying-the-Maximum-Number-of-Runners>
_Specifying the Maximum Number of Runners Used in Workflow a Run <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Specifying-the-Maximum-Number-of-Runners-Used-in-Workflow-a-Run>
_Recycling Powered‐Off Servers <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Recycling-Powered‐Off-Servers>
_Skipping Jobs <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Skipping-Jobs>
_Using Custom Label Prefix <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Using-Custom-Label-Prefix>
_Jobs That Require the Docker Engine <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Jobs-That-Require-the-Docker-Engine>
_Specifying The Runner Type <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Specifying-The-Runner-Type>
_Specifying The Runner Location <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Specifying-The-Runner-Location>
_Specifying The Runner Image <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Specifying-The-Runner-Image>
_Specifying The Custom Runner Server Setup Script <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Specifying-The-Custom-Runner-Server-Setup-Script>
_Specifying The Custom Runner Server Startup Script <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Specifying-The-Custom-Runner-Server-Startup-Script>
_Disabling Setup or Startup Scripts <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Disabling-Setup-Or-Startup-Scripts>
_Specifying Standby Runners <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Specifying-Standby-Runners>
_Specifying Logger Configuration <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Specifying-Logger-Configuration>
_Listing All Current Servers <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Listing-All-Current-Servers>
_Opening The SSH Client To The Server <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Opening-The-SSH-Client-To-The-Server>
_Deleting All Runners and Their Servers <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Deleting-All-Runners-and-Their-Servers>
_Using a Configuration File <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Using-a-Configuration-File>
_Specifying SSH Key <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Specifying-SSH-Key>
_Specifying Additional SSH Keys <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Specifying-Additional-SSH-Keys>
_Running as a Service <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Running-as-a-Service>
_Running as a Cloud Service <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Running-as-a-Cloud-Service>
_Scaling Up Runners <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Scaling-Up-Runners>
_Scaling Down Runners <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Scaling-Down-Runners>
_Handling Failing Conditions <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Handling-Failing-Conditions>
_Meta Labels <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Meta-Labels>
_Estimating Costs <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Estimating-Costs>
_Listing Images <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Listing-Images>
_Deleting Images <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Deleting-Images>
_Creating Custom Images <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Creating-Custom-Images>
_Program Options <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Program-Options>
_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.
Hetzner Cloud <https://www.hetzner.com/cloud>
_ account:❗Warning: You must use a classic token. Fine-grained tokens are not supported.
.. code-block:: bash
pip3 install testflows.github.hetzner.runners
Check that the github-hetzner-runners utility was installed correctly by executing the github-hetzner-runners -v command.
.. code-block:: bash
github-hetzner-runners -v
The github-hetzner-runners utility is installed in the ~/.local/bin/ folder. Please make sure that this folder is part of the PATH.
.. code-block:: bash
which github-hetzner-runners
::
~/.local/bin/github-hetzner-runners
If your PATH is missing this folder on Ubuntu, modify your ~/.profile and add the following section:
:~/.profile: .. code-block:: bash
# set PATH so it includes the user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
For development, you can install from sources as follows:
.. code-block:: bash
git clone https://github.com/testflows/testflows-github-hetzner-runners.git ./package && ./install
Set environment variables corresponding to your GitHub repository and Hetzner Cloud project.
.. code-block:: bash
export GITHUBTOKEN=ghp... export GITHUB_REPOSITORY=testflows/testflows-github-hetzner-runners export HETZNER_TOKEN=GJzdc...
Then, start the github-hetzner-runners program:
.. code-block:: bash
github-hetzner-runners
::
07/22/2023 08:20:37 PM INFO MainThread main 🍀 Logging in to Hetzner Cloud 07/22/2023 08:20:37 PM INFO MainThread main 🍀 Logging in to GitHub 07/22/2023 08:20:37 PM INFO MainThread main 🍀 Getting repository testflows/testflows-github-hetzner-runners 07/22/2023 08:20:37 PM INFO MainThread main 🍀 Creating scale-up services 07/22/2023 08:20:37 PM INFO MainThread main 🍀 Creating scale-down services 07/22/2023 08:20:38 PM INFO worker_2 create_server 🍀 Create server ...
Alternatively, you can pass the required options using the command line as follows:
.. code-block:: bash
github-hetzner-runners --github-token
:✅ Launch your first self-hosted runner in: 5 minutes
This tutorial will guide you on how to use the github-hetzner-runners program to provide autoscaling GitHub Actions runners for a GitHub repository and a Hetzner Cloud project that you'll create.
❶ Before we get started, you will need to install testflows.github.hetzner.runners Python package. See the Installation <https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Installation>
_ section for more details.
.. code-block:: bash
pip3 install testflows.github.hetzner.runners
❷ Check that the github-hetzner-runners utility was installed correctly by executing the github-hetzner-runners -v command.
.. code-block:: bash
github-hetzner-runners -v
::
1.3.230731.1173142
:✋ Note: The github-hetzner-runners utility is installed in to the ~/.local/bin/ folder. Please make sure that this folder is part of the PATH.
.. code-block:: bash
which github-hetzner-runners
::
~/.local/bin/github-hetzner-runners
If your PATH is missing this folder, on Ubuntu, you can modify your ~/.profile and add the following section:
:~/.profile: .. code-block:: bash
# set PATH so it includes the user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
In order to launch the github-hetzner-runners program, we'll need to specify the GitHub repository as well as GitHub and Hetzner Cloud tokens. So, let's create these.
Before using the github-hetzner-runners, you need a GitHub repository with a GitHub Actions workflow set up.
❶ First, create a GitHub repository named demo-testflows-github-hetzner-runners and note the repository name.
The repository name will have the following format:
::