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:
- Navigate to your GitHub repository.
- Click on Settings.
- Select Actions from the sidebar.
- Go to the Runners section.
- Click on Add Runner Group.
- 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.