How to Configure Self-Hosted Runners for your CI/CD Pipelines using GitActions

GABRIEL OKOM
4 min readMay 16, 2024

--

Setting Up Self-Hosted Runners with GitHub Actions.

GitHub Actions and GitHub Runners are both integral parts of GitHub’s ecosystem for automating workflows and tasks within repositories. GitHub Runners allow you to run your GitHub Actions workflows on infrastructure that you control. You can set up self-hosted runners on your own servers, virtual machines, or containers, enabling you to execute workflows in environments that meet your specific requirements.

Step 1: Create an EC2 Instance for the Runner

To create an Ubuntu EC2 instance in AWS, follow these steps in PART ONE or do the following:

Go to the AWS console > search for EC2 > click “launch instances” > type in any unique name > in Application and OS images; select “ubuntu”> for instance type, select “t2.large” with 2vCPU and 8GiB Memory > Create or select a “key-pair” > in network settings; “use same network settings created earlier in Part 1” this is to enable your Runner to be in the same VPC region. > Select a memory size > Launch the instance > After launching the instance, SSH into it as we did in part one of this project series for our “k8s-Master and k8s-Worker” nodes using MobaXterm or any other tool of your choice.

Step 2: Update the system

sudo apt update    

You can use your own repo but if you don’t have; Please clone or fork this repository https://github.com/ougabriel/Boardgame-gabrielokom.git

After the clone or fork > go to the repo settings

In the settings menu; in “Actions” click the dropdown menu > click on “Runners” > Click on “New self-hosted Runner” > select the Runner Image “Linux” > Run the given commands in the newly created EC2 instance or VM.

Step 4: Run the commands

Before we begin, lets change the name of our host machine, to do this run the following command. (You can use any name apart from “gab-Runner”)

hostnamectl set-hostname gab-Runner #changes the name to gab-Runner

Within the “action-runner” directory you should be able to find all these script files.

When running the script “./config.sh” > click enter to accept its default values > when prompted to “Enter the name of runner” choose any name, for example “gab-Runner”

Before the script “./run.sh”

After running the script “./run.sh” ; we can see our Runner has now changed from offline to online or idle signaling us it is now ready for work.

After it is done

We can see our Runner is listening for jobs, do not close the tab. Open a “new tab” to continue working in the runner instance.

The END. >

#gitactions #git #github #selfhosted #selfhostedrunner #gitactionsrunner #runner #GabrielOkom #devops #devopsengineer #cicd

--

--

GABRIEL OKOM
GABRIEL OKOM

Written by GABRIEL OKOM

MSc Cyber Security and Computer Forensics | Certified DevOps Engineer

No responses yet