Saturday, February 24, 2024

How to configure Self-Hosted GitHub Actions Runner | How to install Self-Hosted GitHub Actions Runner | Configure EC2 instance as self-hosted runner in GitHub Actions

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


    • 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.

    Download installables

    # Create a folder

    mkdir actions-runner && cd actions-runner

    # Download the latest runner package

     curl -o actions-runner-linux-x64-2.313.0.tar.gz -L

    # Extract the installer

    tar xzf ./actions-runner-linux-x64-2.313.0.tar.gz

    Configure the runner

    ./ --url --token Token

    Enter the name of the runner group to add this runner to: [press Enter for Default]

    press enter default for the runner group

    Enter name of the runner 


    Enter any additional labels


    Now run the runner


    this confirms that runner is setup and running fine. waiting for the jobs.

    you can also view in GitHub under Runners tab:

    Create a workflow or modify your workflow to include GitHub runner:

    name: Build a WAR file using Maven



        branches: [ "main" ]



        runs-on: self-hosted


        - uses: actions/checkout@v3

        - name: Set up JDK 11
          uses: actions/setup-java@v2
            distribution: 'adopt'
            java-version: '11'
        - name: Build with Maven
          run: mvn clean install -f MyWebApp/pom.xml

    Save the file and run the workflow.

    Go to your virtual machine where build is running:

    Watch steps in YouTube channel:

    No comments:

    Post a Comment

    DevOps Bootcamp Aug 2024 Schedule | DevOps & AWS Azure Cloud Coaching by Coach AK | DevOps and Cloud Computing Online Classes

      (Lot of new topics covered like GitHub Actions, Helm and Monitoring..) The DevOps requirements in the IT market space is expected to grow ...