logo

Running Replay in a Self-Hosted GitHub Action Runner

If your organization hosts its own runner for GitHub actions, you may need some additional configuration to run Replay for your automated tests. However, if you were already running your tests, Replay will likely work without additional configuration.

Using Ubuntu 20.04

The default install of ubuntu 20.04 contains most of what is required to run Firefox and Chromium, but you may need to install the following packages:
shell
sudo apt-get install xorg openbox libdbus-glib-1-dev libgtk-3-0

Using Docker

You can also build a Docker container to run GitHub actions. The Dockerfile below was adapted from testdriven.io and can be used to configure your runner for Replay:
docker
# base FROM ubuntu:20.04 # set the github runner version ARG RUNNER_VERSION="2.292.0" # update the base packages and add a non-sudo user RUN apt-get update -y && apt-get upgrade -y && useradd -m docker ENV DEBIAN_FRONTEND noninteractive ENV DEBCONF_NONINTERACTIVE_SEEN true # install python and the packages the your code depends on along with jq so we can parse JSON # add additional packages as necessary RUN apt-get install -y --no-install-recommends \ curl jq build-essential libssl-dev libffi-dev python3 python3-venv python3-dev python3-pip xorg openbox libdbus-glib-1-dev libgtk-3-0 libnss3 libpci3 libasound2 # cd into the user directory, download and unzip the github actions runner RUN cd /home/docker && mkdir actions-runner && cd actions-runner \ && curl -o actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz -L https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz \ && tar xzf ./actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz # install some additional dependencies RUN chown -R docker ~docker && /home/docker/actions-runner/bin/installdependencies.sh ENV DISPLAY :99 # copy over the start.sh script COPY start.sh start.sh # make the script executable RUN chmod +x start.sh # set the user to "docker" so all subsequent commands are run as the docker user USER docker # set the entrypoint to the start.sh script ENTRYPOINT ["./start.sh"]
The shell script, start.sh, accepts the access token, owner, and repo and is responsible for registering and starting the action runner.
shell
#!/bin/bash ACCESS_TOKEN=$1 OWNER=$2 REPO=$3 cd /home/docker/actions-runner if [[ -z "$REPO" ]]; then echo "Retrieving organization token" REG_TOKEN=$(curl -sX POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${ACCESS_TOKEN}" "https://api.github.com/orgs/${OWNER}/actions/runners/registration-token" | jq .token --raw-output) echo "Registering runner ${REG_TOKEN}" ./config.sh --url https://github.com/${OWNER} --token ${REG_TOKEN} else echo "Retrieving repository token" REG_TOKEN=$(curl -sX POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${ACCESS_TOKEN}" "https://api.github.com/repos/${OWNER}/${REPO}/actions/runners/registration-token" | jq .token --raw-output) echo "Registering runner ${REG_TOKEN}" ./config.sh --url https://github.com/${OWNER}/${REPO} --token ${REG_TOKEN} fi cleanup() { echo "Removing runner..." ./config.sh remove --token ${REG_TOKEN} } trap 'cleanup; exit 130' INT trap 'cleanup; exit 143' TERM ./run.sh & wait $!

Build

plain text
sudo docker build --tag runner-image --platform linux/x86_64 .

Run

repoย can be omitted for an Organization runner
plain text
sudo docker run runner-image <GitHub API Key> <owner> <repo>

Powered by Notaku