Run CI on self-hosted GitHub Actions runners
10 min tutorial
What you'll build
Autoscaling GitHub Actions runners registered to your GitHub org and running on SonicInfra compute, plus a workflow that builds your app and deploys it to a compute instance over SSH — all running on your own infrastructure instead of GitHub's hosted runners.
Prerequisites
- A SonicInfra account with billing enabled.
- Admin access to a GitHub organization.
- A running compute instance to deploy to — see Deploy your first compute instance if you don't have one yet.
Open GitHub Action Runner Sets
Click GitHub Action Runner Sets in the sidebar.
Create a new runner set
Click + Create GitHub Action Runner Set.
Before you create it
Runner sets provision compute VMs to run your jobs — your organization needs billing set up before you can create one.
Haven't set up billing yet? Here's how to add a payment method first.
Configure the runner set
- Web
- CLI
- Terraform
Fill in the fields, then click Create GitHub Action Runner Set:
- Name — used later to target this runner set from a workflow. Use
ci-runnersfor this tutorial. - GitHub Org — the GitHub organization these runners register to. Use an org you're an admin of.
- Min Runners / Max Runners — the pool autoscales between these bounds as jobs queue up.
0–5is a reasonable starting range. - VM Config — cores, memory, and base image for each runner VM. This is a separate image catalog from Compute Instances — use a container disk image like
ubuntu:22.04, not a Compute Instance image slug.
sonic gha-runner-sets create ci-runners \
--githubOrg my-org \
--minRunners 0 \
--maxRunners 5 \
--vm.cores 4 \
--vm.memory 16Gi \
--vm.image dWJ1bnR1OjIyLjA0
# Generated by SonicInfra
# Review before applying — some fields may need adjustment
# (e.g. cloud_init requires a YAML string in the Terraform provider)
resource "sonicinfra_gha_runner_set" "ci_runners" {
name = "ci-runners"
github_org = "my-org"
min_runners = 0
max_runners = 5
vm = { "cores" = 4, "memory" = "16Gi", "image" = "ubuntu:22.04" }
}
Wait for the runner set to come up
Click its row to open the details panel and confirm Ready is true. This can take a couple of minutes the first time, while the runner VMs boot and register with GitHub.
Target it from a workflow
Point a job at your runner set with runs-on, using the Name you gave it instead of ubuntu-latest:
jobs:
build-and-deploy:
runs-on: ci-runners
Unlike GitHub's traditional self-hosted runner labels, this is a single scale-set name, not a list of labels — GitHub Actions Runner Controller (which powers this resource) routes jobs to the pool by that exact name.
Build and deploy from the runner
Put it together into a workflow that builds your app and deploys it to a compute instance over SSH, the same way you would by hand — just triggered by a push instead of a person at a terminal. Replace web-01 below with your own instance's name:
name: Deploy
on:
push:
branches: [main]
jobs:
build-and-deploy:
runs-on: ci-runners
steps:
- uses: actions/checkout@v4
- name: Install and build
run: |
npm ci
npm run build
- name: Deploy over SSH
run: |
sonic ssh web-01 -- 'cd your-app && git pull && npm ci && npm run build && sudo systemctl restart your-app'
Your runner VMs already live on SonicInfra's private network, so sonic ssh reaches your instance the same way it does from your laptop — no public IP or extra network setup needed.