Architecture Overview and Infrastructure Components

You are viewing article number 1 of 12 in the series Scalable Self-Hosted GitHub Runners on AWS Cloud

The following diagram shows the various architecture components in a sample solution for implementing GitHub self-hosted runners.

Green numbered squares are used to break down the architecture into manageable segments. This introductory post provides an overview of each segment, with the aim of addressing the finer build details in subsequent articles.

Image 13
Number Square One Thin

Self-hosted GitHub Runner(s) Registration Token

  • Generation of token to allow ECS containers to register themselves as self-hosted runners within either a GitHub Enterprise/Organization/Repository
Number Square Two Thin

ECR Runner Image Repository

  • Provision ECR repository for storing self-hosted running image
Number Square Three Thin

Hosting Runner Docker Artifacts on CodeCommit

  • Create source code repository for the GitHub runner docker image artifacts
  • The Dockerfile used to build the image would include the Installation of GitHub runner agent
Number Square

Build and Push Runner Image using CodeBuild

  • Create a CodeBuild project (using the CodeCommit repo from previous section as a source) to build and push the Github runner image to ECR
  • Updates to runner agent are released regularly via GitHub’ official public repository: https://github.com/actions/runner
  • Spawning a self-hosted runner using an outdated agent would result in the runner terminating with deprecation messages being issued
  • To ensure the runner agent is kept up-to-date, include a trigger for the CodeBuild project to rebuild and push the image to ECR when new agent releases are available
Number Square Five Thin

Scalable ECS Cluster

Number Square Six Thin

ECS Runner Task Definition

  • Create ECS task definition for self-hosted runner
Number Square Seven Thin

Event Bus and Schema Discover for Webhook Events

  • Create an EventBus for receiving Github webhook events
  • Enable schema auto discovery for the EventBus
  • The events received on the Event bus are inferred into a type, and automatically added to a schema registry
Number Square Eight Thin

Lambda Function URL

  • Lambda Function URL provides an HTTP(s) endpoint which is used to configure a Github webhook (refer to next section)
  • Invocation of the Lambda Function occurs for event types configured through the Github webhook
  • The purpose of the function is to forward the event to Eventbridge, only after webhook payload has been successfully validated (in the case of scaling self-hosted runners, we forward through events related to workflows jobs)
Number Square Nine Thin

GitHub Webhook

  • Using the Lambda URL, configure an appropriate GitHub webhook – either Enterprise/Organization/Repository
Number Square Ten Thin

Event Rule

  • Create an EventBridge rule to invoke an ECS runner task (event target) when a workflow queued event is received

Testing the Final Infrastructure

  • Create an organization repository with test workflows
  • Ensure the runner name is set appropriately within each workflow definition
  • Commit and push a change
  • This should trigger an ECS ephemeral container for each workflow job
Series NavigationECR Runner Image Repository >>