Swiftorial Logo
Home
Swift Lessons
Matchups
CodeSnaps
Tutorials
Career
Resources

Runner Groups in GitHub Actions

Introduction

GitHub Actions allows you to automate workflows for your projects. One of the powerful features of GitHub Actions is the use of Runner Groups. Runner groups allow you to group multiple self-hosted runners together, providing better management and efficiency for running jobs in your workflows.

Key Concepts

  • Runner: A server that runs your GitHub Actions jobs.
  • Self-hosted Runner: A runner that you host yourself, which allows you more control over the environment.
  • Runner Group: A collection of self-hosted runners that you can manage and configure collectively.

Setting Up Runner Groups

Follow these steps to create a runner group:

  1. Navigate to your GitHub repository.
  2. Click on Settings.
  3. Select Actions from the sidebar.
  4. Go to the Runners section.
  5. Click on Add Runner Group.
  6. Name your runner group and save changes.

Using Runner Groups

Once you have set up a runner group, you can specify which group to use in your workflow YAML file:


name: CI

on: [push, pull_request]

jobs:
  build:
    runs-on: [self-hosted, my-runner-group]
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Run build
        run: npm install && npm run build
            

Best Practices

When using runner groups, consider the following best practices:

  • Group runners based on similar workloads to optimize performance.
  • Regularly monitor the usage and performance of each runner group.
  • Keep your runners updated to ensure compatibility with the latest GitHub Actions features.

FAQ

What is the benefit of using runner groups?

Runner groups allow you to manage multiple self-hosted runners more efficiently by grouping them according to specific criteria, such as workload or environment.

Can I mix self-hosted and GitHub-hosted runners in the same workflow?

No, you cannot mix self-hosted and GitHub-hosted runners in the same job. You must specify one type for each job.

How do I delete a runner group?

You can delete a runner group by navigating to the settings of your repository, going to the Actions section, selecting the Runner Groups, and clicking on the delete option next to the desired group.