GitHub Actions

The following guide outlines how to use DevBox as a runtime for GitHub actions.

Pre-built recipe templates are available here.

Using a self-hosted runner

  1. Visit your GitHub repository/org settings page.

  2. Go to Actions > Runners.

  3. Click on "New runner" and select "New self-hosted runner".

  4. Select "Linux" and set "x64" as architecture.

  5. Create a new workspace.

  6. Follow the instructions provided on the page:

mkdir actions-runner && cd actions-runner
curl -o actions-runner-linux-x64-2.317.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.317.0/actions-runner-linux-x64-2.317.0.tar.gz
tar xzf ./actions-runner-linux-x64-2.317.0.tar.gz
./config.sh --url https://github.com/OWNER/REPO --token <token> --labels devzero

Install and start the systemd service:

./svc.sh install && ./svc.sh start

You can also get the registration token non-interactively by sending a http request using curl:

curl \
    -X POST \
    -H "Accept: application/vnd.github+json" \
    -H "Authorization: Bearer "${{ GH_PAT }}"" \
    https://api.github.com/repos/OWNER/REPO/actions/runners/registration-token
  1. Verify that the runner was added to your repo/org and is either in "Idle" or "Online" state.

Tip: The runner name should be same as the DevBox hostname.

  1. Run a GitHub Action on the self-hosted runner to verify that it passes successfully:

name: Actions Demo
on: push
jobs:
  Explore-GitHub-Actions:
    runs-on: self-hosted
    steps:
    - run: echo "🎉 This job uses self-hosted runners!"

Using Actions Runner Controller

You will need a Personal Access Token (PAT).

To create one:

  1. Visit Profile > Developer Settings > Personal access tokens > Tokens (classic).

  2. Click on "Generate new token", select "Generate new token (classic)".

  3. In the "scopes" section, select repo and optionally admin:org for organization runners.

  4. Copy your new Personal Access Token.

After you obtained the PAT:

  1. Create a new workspace with kubectl and helm installed.

  2. Install GitHub Actions Runner Controller using helm.

NAMESPACE=dz-arc-systems
helm install arc \
  --namespace "${NAMESPACE}" \
  --create-namespace \
  oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set-controller

Adjust the INSTALLATION_NAME, NAMESPACE, GITHUB_CONFIG_URL, and GITHUB_PAT variables as needed.

INSTALLATION_NAME="dz-runner-set"
NAMESPACE="dz-arc-runners"
GITHUB_CONFIG_URL=https://github.com/OWNER/REPO
GITHUB_PAT=ghp_token
helm install "${INSTALLATION_NAME}" \
  --namespace "${NAMESPACE}" \
  --create-namespace \
  --set githubConfigUrl="${GITHUB_CONFIG_URL}" \
  --set githubConfigSecret.github_token="${GITHUB_PAT}" \
  oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set
  1. Visit your repository/org settings, select Actions > Runners. Your new runner-set should be listed under "Runner scale sets" with the status shown as "Online".

  2. To verify the installation, run a sample action:

name: Actions Runner Controller Demo
on: push
jobs:
  Explore-GitHub-Actions-Arc:
    runs-on: dz-runner-set # see `INSTALLATION_NAME` above
    steps:
    - run: echo "🎉 This job uses runner scale set runners!"

Last updated