This is a guide on configuring a GitHub action runner for a system for a particular repository. This guide will use the Salt repo (found here) as an example, but it applies to any repo or system.
Github
- Log into GitHub and go to the repository you wish to set up a runner or runners for.
- Go to Settings -> Actions -> Runners (Salt example)
- Click the green "New self-hosted runner" button.
- Toggle the radio button to choose the OS of the runner image. Use the dropdown to choose the appropriate architecture.
- Keep this page with commands handy as you configure the runner on the system.
Runner Setup - RHEL & Ubuntu
While running commands, replace <reponame>
with the name of the GitHub repository that you are configuring the runner for. For Salt, this means I would use gt-salt-coc
- First, create a service account that will run the runner and service. Please ensure you are using the appropriate flags when creating the new service account. We do NOT want this system to have a password or otherwise be able to be logged into.
adduser --no-create-home --system <reponame>-runner
- E.g.,
adduser --no-create-home --system gt-salt-coc-runner
- E.g.,
- If Ubuntu also run:
groupadd --system <reponame>-runner
usermod -aG <reponame>-runner <reponame>-runner
mkdir -p /opt/<reponame>/actions-runner && cd /opt/<reponame>/actions-runner
- Use the curl command from the GitHub page to download the tarball for the runner
- (Optional) Run the command to validate the hash for the tarball
- Extract the tarball
- Change the owner and permission on the extracted files:
chown -R 'root:<reponame>-runner' /opt/<reponame>
chmod -R g+rwx /opt/<reponame>
E.g, chown -R 'root:<reponame>-runner' /opt/gt-salt-coc && chmod -R g+rwx /opt/gt-salt-coc
- Copy the config script line from GitHub and run it as the created service account:
sudo -u <reponame>-runner ./config --url...
- Leave in Default group
- Change the runner name to the following format:
<hostname>_<reponame>
- E.g.,
dev-zfs-res1_gt-salt-coc
- This will be important later to 1) distinguish which host the runner is on and 2) allow one system to host multiple runners for different repos.
- E.g.,
- Add any optional labels. These can be added later.
- Work folder as default (
_work
)
- Congrats, you have successfully installed the runner; however, it needs to be manually run to work at this stage. To further set up this runner as a permanent service...
- Run the service installation script as root:
./svc.sh install <reponame>-runner
- Reload the system's services:
systemctl daemon-reload
- Start and enable the runner service:
systemctl enable --now actions.runner._services.<hostname>_<reponame>.service
- The name of the service should be visible after running the svc.sh install script. If you're having trouble locating the name of the service, run
systemctl list-units | grep actions.runner
- The name of the service should be visible after running the svc.sh install script. If you're having trouble locating the name of the service, run
- Go back into GitHub and refresh the Settings -> Actions -> Runners page. You should see the newly configured runner as online (green dot) but Idle.
Specific categories