GitHub Runners

On Enhancing CI/CD Workflows

Nuwan I. Senaratna
On Technology
3 min readMar 2, 2024

--

GitHub Actions has become a cornerstone for automating software development workflows directly within GitHub. From simple tasks like linting code to complex deployment pipelines, GitHub Actions can handle it all.

Central to its operation are GitHub Runners, the engines that execute the jobs defined in your workflows.

This article dives deep into GitHub Runners, discussing their importance, types, and how they can be customized and managed to optimize CI/CD processes.

What are GitHub Runners?

GitHub Runners are lightweight, scalable virtual machines that execute jobs in a GitHub Actions workflow. Whenever a workflow is triggered — be it by a push event, a pull request, a scheduled event, or manual invocation — the jobs are queued to run on a runner.

Each job within a workflow runs in a fresh instance of a virtual environment, ensuring clean, isolated executions.

Key Features of GitHub Runners

  • Isolation: Each job runs in a separate, clean environment, ensuring that actions executed in one job do not affect subsequent jobs.
  • Scalability: Runners can be scaled horizontally to accommodate the volume of jobs, ensuring that workflows are processed efficiently.
  • Flexibility: GitHub provides hosted runners for Linux, Windows, and macOS environments, but you can also self-host runners for customized environments or specific hardware requirements.

Types of GitHub Runners

There are two main types of GitHub Runners.

1. GitHub-hosted Runners

GitHub-hosted runners are virtual environments maintained by GitHub, offering a quick and easy way to start running workflows without the need to manage infrastructure.

These runners provide environments for Linux, Windows, and macOS and come pre-installed with a wide array of development tools and languages, making them suitable for most CI/CD tasks.

2. Self-hosted Runners

For workflows that require specific configurations, or when you need to run jobs in a private network, self-hosted runners are the solution. You can set up your own machines as runners, giving you full control over the environment, including the operating system, hardware, and installed software.

Self-hosted runners can be more cost-effective for projects with high usage and provide additional flexibility for integrating with internal resources.

Setting Up and Managing GitHub Runners

Setting up a GitHub Runner is straightforward, whether you opt for a GitHub-hosted or a self-hosted runner.

GitHub-hosted Runners

To use a GitHub-hosted runner, simply define the type of runner in your workflow file using the `runs-on` keyword.

name: Example CI Workflow

on: [push]

jobs:
build:
name: Run a one-liner script
runs-on: ubuntu-latest # Specifies the type of runner to use

GitHub will automatically provision a runner that matches the specified environment when the workflow is triggered.

Self-hosted Runners

Setting up a self-hosted runner involves a few more steps:

  1. Provision the Machine: Prepare a virtual or physical machine with the desired operating system and network configuration.
  2. Install the Runner Application: Download and install the GitHub Runner application from your repository, organization, or enterprise settings in GitHub.
  3. Configure the Runner: Register the runner with your GitHub account, specifying the type of work it will handle (e.g., specific repositories or all repositories within an organization).

Managing self-hosted runners includes monitoring their health, updating the runner application, and scaling your fleet of runners based on the workload.

Best Practices for Using GitHub Runners

  • Segregate Workflows: Use different runners for different types of jobs to optimize performance and security. For example, use self-hosted runners for jobs requiring access to private networks and GitHub-hosted runners for public repositories.
  • Monitor and Scale: Regularly monitor the performance and utilization of your self-hosted runners and scale the fleet as necessary to meet demand.
  • Keep Runners Updated: Ensure that the runner application and the software on self-hosted runners are kept up-to-date to leverage new features and security patches.

Concluding Thoughts

GitHub Runners are a powerful feature of GitHub Actions, providing the flexibility and scalability needed to automate CI/CD workflows efficiently. Whether you choose GitHub-hosted runners for their convenience or self-hosted runners for their customizability, understanding how to leverage runners effectively can significantly enhance your software development process.

By following best practices for setup and management, teams can ensure their workflows run smoothly and securely, enabling faster and more reliable software delivery.

--

--

Nuwan I. Senaratna
On Technology

I am a Computer Scientist and Musician by training. A writer with interests in Philosophy, Economics, Technology, Politics, Business, the Arts and Fiction.