Skip to content
play

GitHub Action

Hetzner Cloud Self-Hosted Runner for GitHub CI

v2 Latest version

Hetzner Cloud Self-Hosted Runner for GitHub CI

play

Hetzner Cloud Self-Hosted Runner for GitHub CI

Automatically start cloud instances in the Hetzner Cloud as self-hosted runners for GitHub repositories

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Hetzner Cloud Self-Hosted Runner for GitHub CI

uses: stonemaster/hetzner-github-runner@v2

Learn more about this action in stonemaster/hetzner-github-runner

Choose a version

GitHub Action for Hetzner Cloud Self-Hosted Runners

Automatically start cloud instances in the Hetzner Cloud as self-hosted runners for GitHub repositories. These are started and stopped automatically before and after the GitHub CI run.

Usage

  1. Bootstrap your CI job to create a new hetzner instance:
jobs:
  prepare_env:
    runs-on: ubuntu-latest
    name: Create new Hetzner Cloud instance for build
    steps:
      - uses: stonemaster/hetzner-github-runner@HEAD
        with:
          github-api-key: ${{ secrets.GH_API_KEY }}
          hetzner-api-key: ${{ secrets.HETZNER_API_KEY }}
          hetzner-instance-type: cx11
  1. After this step another workflow can run on this self-hosted machine. Note that this job depends on prepare_env:
jobs:
  [...]
  actual_build:
    runs-on: self-hosted
    needs: prepare_env
    steps:
      - run: env
        shell: bash

Security & Required Keys

Never put the tokens into clear-text but use the Repository secrets feature of the GitHub CI

  • The GitHub API Key provided should just have read/write permission to the Repository Administration. This is needed to obtain a new registration token for your repository that is needed by the GitHub runner.
  • A Hetzner API key needs to be generated for your project according to the offical documentation.