Skip to content
d0njPublic

About

Zero-idle-cost, event-driven self-hosted GitHub Actions runner orchestrator on AWS (Go + Terraform)

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Runlet

Runlet is an open-source, event-driven self-hosted GitHub Actions runner orchestrator on AWS built in Go (provided.al2023, ARM64) and Terraform.

When a GitHub Actions workflow job queues with a matching runner label (such as runlet-arm64), Runlet wakes up via webhook, authenticates as a GitHub App, mints a single-use Just-in-Time (generate-jitconfig) configuration, provisions an ephemeral EC2 instance, runs the single job, and terminates the instance immediately upon exit—with $0 idle compute cost.

See ARCHITECTURE.md for sequence diagrams, IAM boundaries, and engineering trade-offs.

Prerequisites

  • Go 1.26+ (for local tests and building provided.al2023 ARM64 Lambda zips)
  • Terraform 1.6+
  • AWS CLI v2 configured with target account permissions
  • Packer 1.11+ (optional, for pre-baked fast-boot AMIs; stock Ubuntu 24.04 LTS works out of the box)

1. Create a GitHub App

  1. In GitHub Settings -> Developer settings -> GitHub Apps -> New GitHub App:
    • Webhook URL: temporarily use a placeholder (you will update it with Terraform's webhook_url output).
    • Webhook secret: generate a strong random secret (openssl rand -hex 32).
    • Repository permissions:
      • Actions: Read-only
      • Administration: Read & write (required for repository generate-jitconfig and runner deletion rollback)
    • (If using runner_scope = "org", grant Organization permission Self-hosted runners: Read & write instead.)
    • Subscribe to events: check Workflow job.
  2. Generate and download the App's Private key (.pem), note the App ID, and install the App onto your target repository or organization.

2. Store Secrets in AWS SSM Parameter Store

Populate the two SecureString parameters before running terraform apply:

aws ssm put-parameter \
  --name "/runlet/github/webhook-secret" \
  --type "SecureString" \
  --value "YOUR_WEBHOOK_SECRET"

aws ssm put-parameter \
  --name "/runlet/github/app-private-key" \
  --type "SecureString" \
  --value "$(cat path/to/github-app.private-key.pem)"

3. Build Lambda Artifacts & Deploy Infrastructure

make test
make package

cd infra/envs/prod
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars and set github_app_id (and optional pools / spot / region)

terraform init
terraform apply

Note: On AWS Free Tier accounts where c7g.medium is restricted, you can use t4g.small in terraform.tfvars (automatically configured with cpu_credits = "standard").

Copy the webhook_url output from Terraform into your GitHub App's Webhook URL setting.

4. Optional: Bake a Fast-Boot AMI with Packer

Without a custom AMI, scripts/runner-bootstrap.sh automatically installs AWS CLI v2, docker, git, and SHA-256-verified actions/runner on stock Ubuntu 24.04 LTS (~90s boot). To cut startup latency to ~25–35s:

packer init packer/runner.pkr.hcl
packer build -var "aws_region=us-east-1" packer/runner.pkr.hcl

Set the resulting AMI ID in pools["runlet-arm64"].ami_id inside infra/envs/prod/terraform.tfvars and re-run terraform apply.

5. Verify End-to-End

  1. Trigger .github/workflows/demo-runlet.yml via Actions -> Demo Runlet Ephemeral Runner -> Run workflow.
  2. Confirm the job executes on aarch64 as runner with no /run/runlet-jit file present.
  3. Verify in the EC2 console (or via aws ec2 describe-instances --filters Name=tag:runlet:managed,Values=true) that the instance transitions to terminated immediately after the job completes.

6. Teardown

cd infra/envs/prod
terraform destroy

Delete /runlet/github/webhook-secret and /runlet/github/app-private-key from SSM Parameter Store if no longer needed.

About

Zero-idle-cost, event-driven self-hosted GitHub Actions runner orchestrator on AWS (Go + Terraform)

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors