How can I use DevZero as a Github action runner?

‍Using self-hosted Github action runners allows more control over the execution environment than Github-hosted runners provide. They also are free to use with Github actions and do not incur per-minute Github charges. This tutorial walks through how to use a DevZero development environment as a self-hosted Github action runner.

Set up a self-hosted actions runner DevZero Environment #

First, you will need to create a DevZero Environment that can run as a self-hosted Github Actions runner. Follow the instructions on Github to set up the environment, found here: The installation will differ depending on environment. Below is an example setup for a Linux self-hosted runner environment for a go service.

Note that go is installed as it is required for building this project. Accordingly, any dependencies required for executing the Github Actions will need to be installed.

- packagename: jq
- script: | 
    # install go
    sudo snap install go --classic
  runas: devzero
- script: |
    # Create a folder
    mkdir /home/devzero/actions-runner
    # Download the latest runner package
    cd /home/devzero/actions-runner && \
    curl -o actions-runner-linux-x64-2.297.0.tar.gz -L \
    echo "eb4e2fa6567d2222686be95ee23210e83fb6356dd0195149f96fd91398323d7f \
    actions-runner-linux-x64-2.297.0.tar.gz" | \
    shasum -a 256 -c # Extract the installer
    cd /home/devzero/actions-runner && tar xzf ./actions-runner-linux-x64-2.297.0.tar.gz
  runas: devzero

Add a Github personal access token to the DevZero Environment variables #

In order to acquire a token to register the self-hosted runner, a github personal access token needs to be created and added to the template environment. This is used to query the self-hosted runners API for a registration token.

Create a github personal access token with repo scope and add it to the DevZero Environment as an environment variable. Create the token at tokens. Add it as an environment variable with name GH_PAT.

Register the Self-hosted Runner #

Once the Github personal access token is added to the environment, add the script below to the DevZero Environment scriptpolicy to configure and register the runner, modifying the url for the specific repository, replacing OWNER and REPO accordingly in the below snippet. See the Github Runner API docs for more information.

- script: |
    # Create the runner and start the configuration experience
    cd /home/devzero/actions-runner && ./ --url --token $(curl \
    -X POST \
    -H "Accept: application/vnd.github+json" \
    -H "Authorization: Bearer "${{ GH_PAT }}"" \ | jq -r '.token')
  runas: devzero

Configure the runner as a systemd service #

In order to maintain a long-running self-hosted Github actions runner, it must be configured to run as a systemd service. Add the following to your DevZero Environment configuration scriptpolicy:

- script: | 
    # set up runner as systemd service
    cd /home/devzero/actions-runner && sudo ./ install
    cd /home/devzero/actions-runner && sudo ./ start
runas: devzero

This will install and start the runner service in the background. You can verify the service is running by running the following command in your environment terminal:

cd /home/devzero/actions-runner && sudo ./ status

See the documentation for details on configuring a self-hosted runner as a service.

Once the environment is built and running, you should see the github self-hosted runner registered in github. See this documentation for details on how to view runner status.

Configure Github Actions to use Self-Hosted Runners #

Finally, to use your DevZero-based self-hosted Github Action Runners, new and existing workflows must be configured to run on self-hosted runners. Add the following line to the workflow configuration to begin using your DevZero-based runners.

runs-on: self-hosted

For more information on using self-hosted runners for Github Actions see

PreviousHow can I connect to S3?
NextVisual Studio Code Remote Extensions