GitHub Actions is commonly used with GitHub-hosted runners, but some projects need a build environment that matches their production infrastructure. For organizations running applications on Red Hat Enterprise Linux (RHEL), using a RHEL-based runner can make CI/CD workflows more consistent and predictable.
A self-hosted GitHub Actions runner allows you to execute workflow jobs on a machine that your organization manages. You control its operating system, installed tools, network access, hardware resources, and security configuration. This is useful when builds require specific system packages, internal dependencies, private network access, or an environment similar to production.
However, running a self-hosted runner is not simply a matter of installing the runner application and connecting it to GitHub. You also need to manage permissions, updates, workload isolation, and machine availability.
This article explains how to configure GitHub Actions on Red Hat Enterprise Linux, connect the runner to a repository or organization, execute a workflow, and manage the environment safely.
Why Use Red Hat Enterprise Linux for GitHub Actions?
GitHub-hosted runners provide ready-to-use environments, which are convenient for most application builds. However, they do not always match the operating system or infrastructure used by an organization.
Consider a company that develops an ASP.NET Core application and deploys it to servers running Red Hat Enterprise Linux. Its build process might depend on specific Linux packages, native libraries, internal certificates, or scripts that are already configured on RHEL.
Using an Ubuntu-based runner may require additional configuration to reproduce that environment. A RHEL self-hosted runner gives the team more control over the build machine.
Some common reasons to use RHEL runners include:
- Building and testing applications on the same Linux distribution used in production.
- Installing organization-specific packages and native dependencies.
- Accessing internal package repositories and private infrastructure.
- Running integration tests that require access to internal services.
- Controlling hardware resources for resource-intensive builds.
- Applying organization-specific security policies and system configurations.
GitHub's self-hosted runner documentation lists Red Hat Enterprise Linux 8 or later among the supported Linux operating systems. The actual machine must also meet the runner application's requirements and have the necessary network connectivity.
Understanding GitHub-Hosted and Self-Hosted Runners
Before configuring a RHEL runner, it is important to understand the difference between GitHub-hosted and self-hosted runners.
A GitHub-hosted runner is a virtual machine or container managed by GitHub. You select an operating system label in your workflow, and GitHub provides the execution environment.
A self-hosted runner is a machine managed by your organization. It can be a physical server, virtual machine, cloud instance, or another supported environment.
The main differences are:
Area | GitHub-Hosted Runner | Self-Hosted RHEL Runner |
|---|
Infrastructure | Managed by GitHub | Managed by your organization |
Operating system | Selected from available images | Configured by your team |
Software installation | Workflow or image configuration | Direct control over installed tools |
Internal network access | Depends on available configuration | Can be configured for approved internal access |
Maintenance | Mostly managed by GitHub | Your responsibility |
Security configuration | GitHub-managed environment | Your responsibility |
Environment consistency | Depends on selected image | Can match your organization's environment |
A self-hosted runner is not automatically faster or more secure. Its advantages depend on how the machine is configured and maintained.
For many projects, GitHub-hosted runners remain the simplest choice. A self-hosted RHEL runner becomes useful when the build process has specific operating system, infrastructure, or security requirements.
Preparing a Red Hat Enterprise Linux Machine
Start with a RHEL machine that meets the supported operating system and processor architecture requirements.
For this example, assume that you have a RHEL 8 or later x64 virtual machine with administrative access.
Before installing the runner, check the operating system:
cat /etc/redhat-release
Check the processor architecture:
uname -m
For an x64 machine, the expected architecture is:
x86_64
You should also verify that the machine has enough CPU, memory, and disk space for the workloads you plan to execute. A small machine may be sufficient for simple validation jobs, while application builds, container builds, and integration tests may require more resources.
Install commonly used utilities:
sudo dnf install -y curl tar gzip git
The runner distribution also includes a dependency installation script. After extracting the runner package, you can use that script to check and install supported dependencies:
sudo ./bin/installdependencies.sh
Review the script's output and ensure that the required packages are available through your organization's approved repositories.
If the machine uses a proxy or restrictive firewall, verify that it can establish outbound HTTPS connections to GitHub Actions and the other services required by your workflows. Self-hosted runners generally need outbound connectivity over port 443. The exact domains depend on the features your workflows use, including artifact downloads, actions, and container registries.
Creating a Dedicated Runner Account
Avoid running GitHub Actions jobs as the root user. A workflow can execute shell commands, download dependencies, and run scripts from the repository. Giving those jobs unrestricted administrative access increases the potential impact of a compromised workflow.
Create a dedicated Linux account for the runner:
sudo useradd --create-home --shell /bin/bash actions
Switch to the new account:
sudo su - actions
Create a directory for the runner:
mkdir actions-runner
cd actions-runner
This account should have only the permissions required to execute the intended workloads. If a particular build needs access to a privileged operation, handle that requirement separately rather than making the runner account an administrator by default.
Also consider where workflow files, build outputs, and temporary data will be stored. The runner account should not have unnecessary access to system configuration, production credentials, or unrelated application directories.
Downloading and Installing the GitHub Actions Runner
GitHub provides platform-specific runner packages. You can obtain the correct download instructions from the repository or organization settings.
For a repository-level runner, open the repository on GitHub and navigate to:
Settings → Actions → Runners → New self-hosted runner
Select Linux and the appropriate architecture. GitHub displays the download and configuration commands for that runner.
For an organization-level runner, navigate to:
Organization Settings → Actions → Runners → New self-hosted runner
Organization-level runners can be shared across repositories, subject to the runner group's access settings.
The following example illustrates the Linux installation process. Use the download URL and checksum displayed by GitHub for your selected runner version rather than relying on an old package URL.
After downloading the archive, extract it:
tar xzf actions-runner-linux-x64-*.tar.gz
Install the required dependencies if you have not already done so:
sudo ./bin/installdependencies.sh
The runner directory should now contain the configuration and execution scripts, including config.sh and run.sh.
Registering the Runner With GitHub
The runner must be registered with GitHub before it can receive workflow jobs.
When you create a new self-hosted runner in GitHub, the settings page provides a configuration command and a temporary registration token.
Run the command provided by GitHub. It follows this general structure:
./config.sh \
--url https://github.com/OWNER/REPOSITORY \
--token YOUR_TEMPORARY_TOKEN \
--name rhel-build-runner \
--labels rhel,build
Replace the repository URL, token, and other values with the information from your GitHub settings.
The registration token is time-limited and should not be stored in source control, workflow files, or permanent configuration files. Generate a fresh token when required.
During configuration, GitHub may ask you to provide a runner group, working directory, or other settings depending on the registration scope.
The example adds two custom labels:
rhel identifies the operating system environment.build identifies the intended workload.
GitHub automatically assigns default labels such as self-hosted, linux, and the processor architecture. Custom labels help you route jobs to runners with specific tools or capabilities.
Once registration completes, GitHub should display the runner in the repository or organization runner settings.
Running the Runner as a Linux Service
Starting the runner manually with run.sh is useful during initial testing. However, a production runner should generally run as a service so that it can start automatically and continue accepting jobs without requiring an administrator to keep a terminal session open.
From the runner directory, install the service:
sudo ./svc.sh install actions
Start it:
sudo ./svc.sh start
Check its status:
sudo ./svc.sh status
The service uses the runner configuration and runs under the configured account. If you need to troubleshoot the service, identify its systemd unit and inspect its logs:
systemctl list-units --type=service | grep actions.runner
Then use the relevant service name:
sudo journalctl -u SERVICE_NAME -f
Replace SERVICE_NAME with the actual unit name returned by the previous command.
Running the service under a dedicated account helps separate workflow execution from routine system administration. It also makes the runner easier to manage after machine restarts.
Configuring a GitHub Actions Workflow for RHEL
After registration, you can target the RHEL machine through its runner labels.
Create a workflow file in your repository:
.github/workflows/rhel-build.yml
The following example checks out the repository, displays the operating system information, and builds a .NET application:
name: Build on RHEL
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build Application
runs-on: [self-hosted, linux, x64, rhel]
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Display operating system
run: |
cat /etc/redhat-release
uname -m
- name: Check .NET SDK
run: dotnet --info
- name: Restore dependencies
run: dotnet restore
- name: Build application
run: dotnet build --configuration Release --no-restore
- name: Run tests
run: dotnet test --configuration Release --no-build
The runs-on value contains four labels. GitHub selects an online and idle runner that matches all of them.
The self-hosted, linux, and x64 labels are automatically assigned to a compatible runner. The rhel label is custom and must be assigned during runner configuration or added through the runner settings.
The workflow assumes that the required .NET SDK is already installed and available to the runner account. If the application targets a particular .NET version, install and maintain that SDK on the machine or configure a controlled tool-installation process.
You can verify the installed SDK with:
dotnet --list-sdks
If the runner does not have the required SDK, the build will fail even if the runner itself is online.
Managing Runner Security and Permissions
Self-hosted runners require more security attention than a typical GitHub-hosted build environment because they operate on infrastructure controlled by your organization.
A workflow can execute commands on the runner machine. If an untrusted contributor can modify a workflow or execute arbitrary code through a pull request, that code may be able to access files, credentials, or network resources available to the runner account.
This is especially important when the runner can reach internal systems.
Consider the following practices:
- Use a dedicated, unprivileged Linux account for runner execution.
- Avoid storing production credentials directly on the runner.
- Restrict repository access through runner groups.
- Limit access to sensitive internal networks.
- Keep the runner operating system and installed software updated.
- Review workflow permissions and third-party actions.
- Avoid running untrusted pull request code on persistent runners that contain sensitive information.
For workloads that need stronger isolation, consider ephemeral runners. An ephemeral runner is registered to process a single job and is automatically deregistered by GitHub after completing that job.
You can configure an ephemeral runner using:
./config.sh \
--url https://github.com/OWNER/REPOSITORY \
--token YOUR_TEMPORARY_TOKEN \
--ephemeral
This does not automatically destroy the underlying virtual machine. Your infrastructure automation must clean up or rebuild the machine after the job finishes.
Ephemeral runners are particularly useful for automated runner environments where each job should start with a clean machine. Make sure runner logs are forwarded to external storage before the machine is removed so that failures can still be investigated.
Common Problems When Running GitHub Actions on RHEL
A correctly registered runner can still experience problems during workflow execution. The most common issues involve dependencies, permissions, network connectivity, and label configuration.
Runner Appears Offline
If GitHub shows the runner as offline, first check the service:
sudo ./svc.sh status
Inspect the service logs and verify that the machine can reach GitHub over HTTPS. Firewall rules, proxy configuration, DNS failures, and expired or invalid configuration can prevent the runner from connecting.
Workflow Remains Queued
A workflow can remain queued when GitHub cannot find an online, idle runner matching every requested label and group.
Compare the workflow's runs-on labels with the labels displayed in GitHub runner settings. A mismatch such as requesting rhel-build when the runner only has rhel will prevent the job from being assigned.
Also verify that the runner is online and permitted to process jobs from the repository.
Build Fails Because a Tool Is Missing
A self-hosted runner does not automatically include the software available on GitHub-hosted images.
For example, a workflow that runs dotnet build requires the .NET SDK to be installed and available in the runner's environment. The same applies to Java, Node.js, Docker, compilers, and other build tools.
Maintain a documented list of required tools and validate their availability before running the main build.
Permission Denied During a Build
Permission errors can occur when the runner account cannot access a directory, execute a script, or write to a build location.
Check the ownership and permissions of the affected path:
ls -ld /path/to/directory
Correct the permissions for the specific resource rather than granting broad access to the runner account.
Best Practices for Production RHEL Runners
A self-hosted runner should be treated as part of your CI/CD infrastructure, not as a one-time installation.
Keep the operating system patched, monitor available disk space, and regularly review the tools installed on the machine. Runner software should also remain current. If automatic runner updates are disabled, your team must manage updates and ensure the runner continues to meet GitHub's minimum supported version requirements.
For larger teams, organize runners into groups based on their purpose. For example, application builds, integration tests, and deployment workflows may require different permissions and infrastructure access.
Avoid sharing one powerful runner across unrelated repositories without reviewing their trust boundaries. A runner used for internal deployment should not automatically be available to every repository in an organization.
For workloads that require autoscaling, use ephemeral runner infrastructure rather than relying on a collection of permanently registered machines. This makes it easier to provide clean execution environments and reduce the impact of a compromised job.
Finally, monitor runner availability, job duration, failed jobs, disk usage, and service health. These signals help identify infrastructure problems before they repeatedly interrupt development work.
Summary
Running GitHub Actions on Red Hat Enterprise Linux gives organizations greater control over their CI/CD environment. It is particularly useful when applications depend on RHEL-specific packages, internal services, or build configurations that need to match production infrastructure.
The setup involves preparing a supported RHEL machine, creating a dedicated runner account, installing and registering the GitHub Actions runner, configuring it as a Linux service, and targeting it through workflow labels.
The installation itself is straightforward, but long-term reliability depends on security, maintenance, monitoring, and workload isolation. For production environments, dedicated runner accounts, restricted runner groups, regular updates, and ephemeral execution environments help make self-hosted GitHub Actions more manageable and secure.
Join the conversation! Your thoughts help the community grow.