This repository contains an example how to run self-hosted GitHub Actions runners on AWS Fargate!
The solution presented in this repository is available as a Construct library in NPM and GitHub.
You can import it to your project by:
import { GithubActionsRunner } from "@cloudgardener/cdk-aws-fargate-github-actions-runner";Docker image is based on ubuntu:20.04 / focal. I may consider moving back to ubuntu:rolling once actions/runner#1584 is resolved.
On top the base image I have installed GitHub Actions Runner based on About self-hosted runners in GitHub documentation.
The application is deployed to AWS using AWS Cloud Development Kit (AWS CDK).
- Store two parameters
GITHUB_ACCESS_TOKENandGITHUB_ACTIONS_RUNNER_CONTEXTin to SSM Parameter Store.- For repository level runner set
GITHUB_ACTIONS_RUNNER_CONTEXTvalue tohttps://github.com/<owner>/<repository> - For organization level runner set
GITHUB_ACTIONS_RUNNER_CONTEXTvalue tohttps://github.com/<organization>
- For repository level runner set
- Run
cdk synth --profile <your-aws-cli-profile> - Run
cdk deploy --profile <your-aws-cli-profile> - Wait a little while ...
Now you should be able find your self-hosted runner from repository setting in GitHub:
We can see also from the Fargate Task Logs that the runner is successfully registered:
Registering self-hosted runner to repository level requires admin access to the repository, and repo scope for the access token.
Registering self-hosted runner to Organization level requires admin access to the organization, and admin:org scope for the access token.
You can read about the comparisions I made from Price Comparision document.
npm run buildcompile typescript to jsnpm run watchwatch for changes and compilenpm run testperform the jest unit testscdk deploydeploy this stack to your default AWS account/regioncdk diffcompare deployed stack with current statecdk synthemits the synthesized CloudFormation template



