A self-hosted GitHub runner is a machine (physical or virtual) that you set up and manage to run GitHub Actions workflows. A self-hosted runner differs from the default GitHub-hosted runners in that it runs on infrastructure that you control. Self-hosted runners can be physical, virtual, in a container, on-premises, or in a cloud. To learn more about GitHub runner, please click here.
Advantages of self-hosted runners:
full control over the environment and tools
Any size machine or configuration
Secure access and networking
Pre-requisites:
Project configured in GitHub
workflow yaml already checked-in GitHub. If you don't have one, click here to create one.
Create a virtual machine with at least 2 GB RAM. we will use EC2 instance in AWS cloud.
Install Maven on runner EC2 instance
How to create self-hosted GitHub Actions Runner?
Go to GitHub Repo--> Actions --> Runners
Click on self-hosted runners --> New Runner
Click on Linux
Perform update
sudo apt update
Install Maven in Runner EC2 as We will be doing Maven build for Java project
sudo apt install maven -y
Execute below commands in your virtual machine to configure runner.
Here below are the Ansible Roles for installing Java, Jenkins, Maven on Ubuntu EC2 instance using Ansible. You need to installJava first (first link below) and then do the steps in the second link for installing Jenkins, third link for installing Maven.
Click here if you would like to create a new Ubuntu EC2 instance using Ansible Playbook.
You can watch this lab on YouTube:
Pre-requisites: Setup Ansible on your EC2 instance.