AWS, Cloud Computing, DevOps

3 Mins Read

A Guide to Configure a Self-hosted GitHub Runner on an Amazon EC2 Machine

Voiced by Amazon Polly

Introduction

GitHub Actions provide a powerful and flexible platform for automating workflows directly within your GitHub repository. Configuring a self-hosted GitHub runner on an Amazon EC2 machine becomes valuable when you require more control over your build environment. This blog post guides you through setting up a self-hosted runner on Amazon EC2.

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

Prerequisites

Before you begin, ensure you have the following:

  • An active GitHub repository.
  • An Amazon EC2 instance with a valid SSH key pair.
  • AWS CLI is installed locally for convenient Amazon EC2 instance setup.

Step-by-Step Guide

Step 1: Launching an Amazon EC2 Instance

Launch an Amazon EC2 instance using the AWS Management Console or AWS CLI. Make sure to select an instance type that aligns with your workload requirements. Note down the public IP address or DNS of the instance.

Step 2: Installing Dependencies on Amazon EC2

SSH into the Amazon EC2 instance and install the necessary dependencies:

Step 3: Select the repository on which you want to have the runners and click on New-Self-hosted-runner.

step3

Step 4: Select the runner image according to your server Operating system.

step4

Step 5: GitHub provides the detailed commands to run on your Amazon EC2 server to configure the runners, download the commands, and run them as shell scripts, or you can run each command on the server.

step5

Step 6: The server will authenticate with GitHub with the runner token and enable your server to be listed as a hosted runner.

step6

step6b

step6c

Step 7: Once the runner is configured then the server will be visible as hosted runners in your GitHub account.

step7

Conclusion

Configuring a self-hosted GitHub runner on an Amazon EC2 instance gives you greater control over your build environment, enabling customized workflows tailored to your project’s needs.

With this setup, you can take full advantage of GitHub Actions while maintaining the flexibility of your infrastructure.

Drop a query if you have any questions regarding Self-hosted GitHub and we will get back to you quickly.

Making IT Networks Enterprise-ready – Cloud Management Services

  • Accelerated cloud migration
  • End-to-end view of the cloud environment
Get Started

About CloudThat

CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, and Google Cloud Platform Partner, CloudThat has empowered over 850,000 professionals through 600+ cloud certifications winning global recognition for its training excellence including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 12 awards in the last 8 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, IoT, and cutting-edge technologies like Gen AI & AI/ML. It has delivered over 500 consulting projects for 250+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.

FAQs

1. Can I use a self-hosted GitHub runner across multiple repositories?

ANS: – Yes, a self-hosted GitHub runner can be used across multiple repositories. During the runner configuration

2. What security considerations should I be aware of when using self-hosted GitHub runners?

ANS: – When using self-hosted GitHub runners, consider the following security best practices:

  • Access Controls: Ensure only authorized individuals can access the self-hosted machine and runner configuration files.
  • Token Management: Safeguard your access tokens used during runner configuration. Avoid hardcoding tokens directly in scripts or configuration files.
  • Update Regularly: Keep your self-hosted machine and all dependencies up-to-date with the latest security patches.
  • Isolation: Consider using dedicated machines for self-hosted runners to avoid potential security risks associated with sharing the environment.
  • Firewall Rules: Configure firewall rules to restrict network access to only necessary services and ports.

WRITTEN BY Rekha S

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!