Setting up a self-hosted GitHub Runner
This article explains how to set up a self-hosted GitHub Runner in eclean's infrastructure. Following these steps ensures that all runners are configured consistently and securely.
Security sensitive
This document includes security-sensitive information about our infrastructure configuration. Before proceeding, make sure to follow security protocols and have correct authorisation.
Prerequisites
Your own toolset
Self-hosted GitHub Actions runners do not come with their own tool set, as they do on the cloud. You must manually install all dependencies required by your repository, unless you are utilizing the "github-act-runner" setup and running just Ubuntu workloads, in which case you can use the given Docker image.
Before starting the runner configuration process, make sure you have:
- A Windows machine with administrator access
- Required firewall rules documented and authorised
- GitHub repository access with permissions to add runners
Runner Configuration Steps
1. System Updates and WSL
Start by updating Windows and installing WSL (Windows Subsystem for Linux).
Update Windows
- Open Windows Settings
- Go to Windows Update
- Check for updates and install all available updates
- Restart if required
Install and Update WSL
2. Install Package Manager and Core Tools
We use Scoop as our package manager for Windows. Install it using PowerShell:
PATH and file associations
Scoop will automatically provide most of the required instructions for adding freshly installed applications to the PATH and file associations.
To ensure optimal GitHub Runner functionality, add the PATH variables to the system PATH variable rather than only the user PATH variable (which Scoop will do by default).
3. Manual Application Installation
Some applications need to be installed manually due to licensing or specific configuration requirements.
Docker Desktop
- Download Docker Desktop from the official website
- Run the installer with default settings.
- Restart your computer after installation.
Portmaster
- Download Portmaster from safing.io
- Install with default settings
-
Configure DNS settings:
Disable the "Block Secure DNS Bypassing" option in "Global Settings > Privacy Filter > Advanced".
-
Configure RDP security:
- Block all connections except
YOUR_COUNTRY_TWO_LETTER_CODE TCP/3389andYOUR_COUNTRY_TWO_LETTER_CODE UDP/3389on the "Windows Service: Term Service" process- E.g.
SE TCP/3389andSE UDP/3389for Sweden
- E.g.
- Block all connections except
Node.js via nvm
GitHub Actions runners require Node.js v20.x. Install it using nvm:
The command to use Node.js v20.x will show in the output of the previous command.
4. System Optimization
Compress Windows Installation
Run the following command to enable system compression:
5. HetrixTools Setup
Creating the uptime monitor
Use the " Setup Ubuntu 24.04 server" guide to create the HetrixTools uptime monitor before proceeding.
- Install the HetrixTools server monitoring agent for Windows
- Configure Portmaster to allow ICMP echo requests from HetrixTools IPs:
- You can find the appropriate IPs for each HetrixTools region at https://docs.hetrixtools.com/uptime-monitoring-ip-addresses/
- The configuration should be applied in the "Global Settings > Privacy Filter > Connection types > Incoming Rules"
- Configure the Windows Firewall to allow ICMP echo requests:
- Open the Windows Firewall with Advanced Security
- Go to "Inbound Rules"
- Click "New Rule"
- Under "Rule type", select "Custom"
- Under "Protocol and ports", select "ICMPv4"
- Click "Customize"
- Under "Specific ICMP types", select "Echo Request"
- Give the rule a name and description, then apply the rule
6. GitHub Runner Installation
Runner Registration
You'll need a runner registration token from the GitHub repository or organization settings to complete this step.
Runner image
We recommend pulling the Docker image used for Ubuntu support from the catthehacker/docker_images repository to save time later when the Actions workflows need to be run.
You will most likely require either ghcr.io/catthehacker/ubuntu:act-latest or ghcr.io/catthehacker/ubuntu:full-latest. However, full-latest provides a more comprehensive collection of tools and is generally recommended, but it also takes up more disk space (60GB when uncompressed).
Please select the suitable image based on your requirements and your system's specifications and capabilities.
Do you have all dependencies installed?
Before proceeding, ensure that Docker Desktop is installed and setup for WSL 2 integration. You may also need to enable the "Expose daemon on tcp://localhost:2375 without TLS" option in Docker Desktop to allow the runner to connect.
- Download the ChristopherHX/github-act-runner binary
- Place the downloaded binary in
C:\github-act-runner -
Create a new
.envfile in the same directory as the binary with the following content:Note: The
PATHvariable should be a copy of your system PATH variable, not just the user PATH variable. A production example of thePATHvariable is provided below:%SystemRoot%;%SystemRoot%\system32;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\OpenSSH\;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Docker\Docker\resources\bin;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\scoop\shims;C:\Users\Administrator\scoop\apps\git\current;C:\Users\Administrator\scoop\apps\nvm\current;C:\Users\Administrator\scoop\apps\nvm\current\nodejs\nodejs;C:\Users\Administrator\scoop\persist\nvm\nodejs\nodejs;C:\Users\Administrator\scoop\apps\bun\current;C:\Users\Administrator\scoop\apps\rustup\current;C:\Users\Administrator\scoop\apps\rustup\current\.cargo\bin;C:\Users\Administrator\scoop\persist\rustup\.cargo\bin;C:\Users\Administrator\scoop\persist\rustup\.rustup\toolchains\stable-x86_64-pc-windows-msvc\bin;C:\Users\Administrator\scoop\apps\vscodium\current\bin;C:\actions-runner\bin;C:\github-act-runner-v0.9.0; -
Run the
configure.batscript and follow the instructions- When asked for runner labels, make sure to include
windows,ubuntu, andact-runner, as well as the hosting provider (e.g.,azure,aws,royalehosting, etc.)WindowsandUbuntuidentify the runner as able to run Windows and Ubuntu workloads, respectively.act-runnerrecognizes the runner as a "github-act-runner".- The hosting provider is optional but preferred because it assists with filtering and grouping runners in the GitHub repository settings.
- When asked for runner labels, make sure to include
- Run
./github-act-runner.exe svc installto install the runner as a service - Run
./github-act-runner.exe svc startto start the runner as a service - Update your workflows to use the self-hosted runner correctly:
- Use the
runs-onsetting to specify the runner labels- E.g.
runs-on: ["self-hosted", "ubuntu", "act-runner"]
- E.g.
- Use the
containersetting to specify the Docker image to use- E.g.
container: ghcr.io/catthehacker/ubuntu:act-latest
- E.g.
- Use the
Do you have all dependencies installed?
Before proceeding, ensure that Docker Desktop is installed and setup for WSL 2 integration. You may also need to enable the "Expose daemon on tcp://localhost:2375 without TLS" option in Docker Desktop to allow the runner to connect.
- Download the GitHub Actions runner for Windows
- Extract the downloaded archive to
C:\actions-runner - Follow the official GitHub documentation to complete the runner configuration
- When asked for runner labels, make sure to include
windows,gha-native, and the hosting provider (e.g.,azure,aws,royalehosting, etc.)windowsidentifies the runner as able to run Windows workloadsgha-nativeidentifies the runner as a native GitHub Actions runner- The hosting provider is optional but preferred because it assists with filtering and grouping runners in the GitHub repository settings.
- When asked for runner labels, make sure to include
- Update your workflows to use the self-hosted runner correctly:
- Use the
runs-onsetting to specify the runner labels- E.g.
runs-on: ["self-hosted", "windows", "gha-native"]
- E.g.
- Use the