Jump toUpdate content
Hosting your own GitHub runner on an Instance
GitHub Actions is a flexible tool that makes it easy to automate all your software workflows. It provides you with an integrated CI/CD that automates nearly anything related to your repository.
GitHub provides a limited range of free resources to build your applications through GitHub Actions, and professional developers can reach these limits quickly. Teams working on professional projects may also prefer to have complete control over their build environment. GitHub provides the possibility to execute runners on self-managed Instances. A runner is an application that runs a job from a GitHub Actions workflow.
In this tutorial, you learn how to set up a GitHub Actions runner on a Scaleway Instance to automatize the workflow of your projects. For most common workloads, the use of Cost-Optimized Instance is recommended. Demanding workloads can be deployed on Production-Optimized Instances for dedicated resources.
We recommend you follow this tutorial using a Cost-Optimized Instance.
You may need certain IAM permissions to carry out some actions described on this page. This means:
- you are the Owner of the Scaleway Organization in which the actions will be carried out, or
- you are an IAM user of the Organization, with a policy granting you the necessary permission sets
- You have an account and are logged into the Scaleway console
- You have configured your SSH key
- You have created an Instance that runs Ubuntu 20.04
- You have sudo privileges or access to the root user.
- You have a GitHub account
Adding a workflow to your repository
- Log into your GitHub account and select the repository in which you want to add GitHub Actions.
- Click the Actions tab in your repository. A list of available workflows for your project displays.
- Select the workflow that corresponds to your project and click Set up this workflow. You can either create a workflow from scratch or use one of the templates suggested.
- Edit the workflow according to your requirements. For more information about GitHub Actions, refer to the product documentation. Once configured, save the workflow.
Installing a GitHub runner
- Connect to your Instance via SSH.
- Create a user for the GitHub runner.
- Add the user to the superuser file:
adduser ghrunner sudo
- Switch into the
ghrunneruser accountsu ghrunner
- Download and unpack the GitHub runner using the following commands:
# Create a foldermkdir actions-runner && cd actions-runner# Download the latest runner packagecurl -O -L https://github.com/actions/runner/releases/download/v2.302.1/actions-runner-linux-x64-2.302.1.tar.gz# Extract the installertar xzf ./actions-runner-linux-x64-2.302.1.tar.gzTip:
You may check the GitHub runner repository for the latest release of the runner.
Adding the runner to your GitHub repository
Go back to your GitHub repository and click the Settings tab. Then click Actions in the side menu.
Click Runners in the Actions section of the side menu. The external runners overview page displays.
Click Add runner.
The runners configuration instruction displays. Select the OS type of your OS (Linux, X64) and scroll down to Configure section of the page.
Copy the configuration information displayed and execute the
config.shon your Instance:./config.sh --url https://github.com/scaleway-community/my-project --token AC6XRSJUUEWXLYJ7SQ6WMVLASKYWZNote:
If you run the
config.shscript without flags, you must provide the repository URL and token during the configuration.
The configuration tool connects to GitHub using the given token.
Enter the name of the runner during the runner configuration. It gets automatically several tags attached to it. Optionally you can enter custom tags. When prompted, enter the
workdirectory of the runner. You can confirm the default values by pressing enter. Otherwise enter your customized values before pressing enter.
The runner is configured. Once everything is ready, the following message displays:√ Runner successfully added√ Runner connection is good[...]√ Settings Saved.
Launch the runner using the following command:./run.sh
Your self-hosted GitHub runner is now ready and you can check its status from the Runners section of your GitHub repository:
To run your CI/CD tasks on your self-hosted runner, add this YAML in your workflow file for each job:
For more information about GitHub runners, refer to the official documentation.