Setup a Github Self-Hosted Runner
Workshop progress
Completed 0 of 16 steps
- Introduction
- Account and API Key Setup
- Fork a Repo and Deploy a Server
- Setup a Github Self-Hosted Runner
- Execute a Github Action on your Runner
- Conclusion
In this steps we'll be getting familiar with GitHub Self-Hosted Runners. If it's your first time using Self-Hosted Runners, take a few minutes to flip through their documentation.
Steps
1. Setup your forked repo to use Self-Hosted Runners
Navigate to your metal-cli
fork. For me it's https://github.com/cprivitere/metal-cli, however it'll be different per person. It'll be in the format:
https://github.com/<your-github-username>/metal-cli
Click on the Settings tab, you should see a view like this:
On the left bar, click on Actions, then Runners.
To create a new Self-Hosted Runner, click the new self-hosted runner button.
Choose the correct OS and architecture option, if you're using the recommend system from the previous step, it would be Linux and x64.
You should now see instructions for downloading, configuring, and using the GitHub Runner software.
Step 11 of 16
2. Run the commands to download and configure the runner
The first step to installing the GitHub Runner software would be to SSH into the machine you created earlier.
ssh root@your-metal-server
You'll also need to install gcc
, create a new user, and switch to it. Github Runners do not run as root
.
apt update
apt install build-essential gcc
useradd -m ghrunner -s /bin/bash
su - ghrunner
Next, copy and paste the Download and Configure sections from the Add New Runner page from the previous step.
!!! note
- Take the defaults by just pressing enter when it asks for the group, name, labels, and work folder.
- Don't forget to run
./run.sh
- If you were doing this as a long lived runner in production this would be better executed as a systemctl service, but long lived runners are not recommended, so just running
./run.sh
inline is fine for today.
Your runner should now say it's Listening for Jobs.
Step 12 of 16
Discussion
Before proceeding to the next part let's take a few minutes to discuss what we did. Here are some questions to start the discussion.
- Can you have more than one self-hosted runner?
- What sorts of pre-requisites would your code repositories need on your own runners?
- How should I secure my runners?
Step 13 of 16