Skip to content

sakamoto66/aws-batch-github-runner

Repository files navigation

AWS Batch for self hosted GitHub action runners

Launch a self-hosted runner with the flag "--ephemeral" via AWS Batch.
It will be automatically terminated under any of the following conditions of the instance.

  • The processing of the first job is finished
  • I did not receive a job for a certain period of time after starting (default:120sec)

Configuration Diagram

Setup

Step1. fork repository

  • this repository fork

Step2. Create Github Personal access token

  • Note: github self hosted runner
  • Expiration: <Any>
  • Select scopes: repo

Step3. Regist Github Personal access token in AWS Secrets Manager

  • run terraform
$ cd regist-secret-key
$ terraform init
$ terraform plan
$ terraform apply
var.github_personal_access_token
  Enter a value: `<Github Personal access token>`
$ cd ..

Step4. Setup AWS Batch

  • run terraform
./generate-region.sh
$ cd terraform
$ terraform init
$ terraform plan
$ terraform apply
var.github_account
  Inputs github user or organization or '*'.

  Enter a value: 
var.github_repository
  Inputs repository or '*'.

  Enter a value: 
$ cd ..
  • memo Value of AWS_ROLE_ARN.

Step5. Regist Secret in GitHub repository

  • Key
    • AWS_ROLE_ARN
  • Value
    • <memo of Step4>

Step6. Build Github Self Hosted Runner

  • run .github/workflows/updateSelfHostRunner.yml on forked repository

Step7. test

  • run .github/workflows/hello.yml on forked repository