Buy Me a Coffee

[GitHubRunner] How to Set Up a Self-Hosted GitHub Runner in a DigitalOcean Droplet

Setting Up a GitHub Runner in DigitalOcean

Setting up a self-hosted GitHub Runner on a DigitalOcean droplet allows for more control and customization in your CI/CD pipelines. This guide walks you through creating a droplet using a Docker image, configuring GitHub secrets, and setting up a self-hosted runner in a few easy steps.

1. Setup DigitalOcean Droplet

1.1 Create a DigitalOcean Droplet

Start by creating a droplet from the DockerImage marketplace on DigitalOcean. This pre-configured image includes Docker, so you won’t need to install it yourself.

Create Droplet

Create Droplet

Choose a secure password for SSH access and save it somewhere safe.

1.2 Configure GitHub Repository Secrets

Navigate to your GitHub repository and open the settings tab. Under Secrets and variablesActions, add a new repository secret.

Configure Secrets

2. Configure GitHub Action Runner

In GitHub, go to ActionsRunners and set up a new self-hosted runner. Select Linux and the X64 Architecture.

GitHub Runner

Since the GitHub runner should not run as the root user (the default for DigitalOcean droplets), create a non-root user and add this user to the Docker group.

SSH into your droplet:

SSH Console

2.1 Create a Non-Root User and Add to Docker Group

If you can run docker commands with your current user, you can skip the next step.

If you couldn’t run docker command with a non-root user, before following the Github Runner installation instruction, you should create a user for Github Runner and add it into docker group. Below are the commands to create a new user and set the required permissions:

newgrp docker
sudo su

# Create a password when prompted and save it.
adduser githubrunner 

# you will be prompted to add password for this user. Save it somewhere safe.
usermod -aG sudo githubrunner

# Switch to the githubrunner user
su - githubrunner 

sudo usermod -aG docker $USER

# Verify that you can run docker commands without sudo now
docker version

Create User

2.2 Install and Configure the GitHub Runner

Now you can proceed with the GitHub Runner setup instructions step by step. Download the runner package, extract it, and configure it using the token provided in the GitHub Actions runner setup page. Note that to choose the correct Operating System and Architecture.

Runner Installed

Runner Installed

2.3 Run the GitHub Runner

After you run the configuration command ./config.sh --url https://github.com/xxx --token <token>, you will be prompted to Enter the name of the runner group to add this runner to, you can just press Enter to accept the default value.
The next prompt is Enter the name of runner, you can also press Enter to accept the default value.

Runner Installed

The next prompt is *This runner will have the following labels: ‘self-hosted’, ‘Linux’, ‘ARM64’ Enter any additional labels (ex. label-1,label-2): *, you can add your custom label here or just press Enter to accept the default value.

❗ After executing the configuration command ./config.sh --url https://github.com/xxx --token <token>, instead of running ./run.sh, execute it in the background using nohup:

nohup ./run.sh &

Upon successful execution, check back on the Actions → Runners page, and your newly installed runner should be visible.

Runner Active

With these steps, you can now leverage the power of a self-hosted runner directly from your DigitalOcean droplet, optimizing your GitHub Actions for better control and efficiency.


Enjoyed this article? Support my work with a coffee ☕ on Ko-fi.
Buy Me a Coffee at ko-fi.com
DigitalOcean Referral Badge
Sign up to get $200, 60-day account credit !