Skip to content

Restore Github Runner VM

benoit74 edited this page Oct 28, 2024 · 4 revisions

Order VM / Machine at provider

Nothing special

Setup node

Follow standard procedure at https://github.com/kiwix/operations/wiki/Machine-and-k8s-node-Setup

Create a non-root user (member of sudoers):

useradd -m -s /bin/bash user
usermod -aG sudo user

Modify (with visudo) the sudoers configuration to ensure sudoers can sudo with passwords:

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) NOPASSWD: ALL

Copy /root/.ssh/authorized_keys to /home/user/.ssh/authorized_keys and chown it to user:user:

mkdir -p /home/user/.ssh
cp /root/.ssh/authorized_keys /home/user/.ssh/authorized_keys
chown -R user:user /home/user/.ssh

Add perl package to have shasum utility

apt install perl

Install dependencies needed by your jobs

Docker

Follow normal procedure at https://docs.docker.com/engine/install/debian/

Add user to docker group:

sudo usermod -aG docker user

Install Github runner

Main documentation is at https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/adding-self-hosted-runners#adding-a-self-hosted-runner-to-an-organization and https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/configuring-the-self-hosted-runner-application-as-a-service

Login as user (not root)

Install the runner in /etc/actions-runner (where <your_token> is a token given by github on organization settings -> actions -> runners):

sudo mkdir /etc/actions-runner && cd /etc/actions-runner
sudo chown user:user /etc/actions-runner
curl -o actions-runner-linux-x64-2.320.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.320.0/actions-runner-linux-x64-2.320.0.tar.gz
echo "93ac1b7ce743ee85b5d386f5c1787385ef07b3d7c728ff66ce0d3813d5f46900  actions-runner-linux-x64-2.320.0.tar.gz" | shasum -a 256 -c
tar xzf ./actions-runner-linux-x64-2.320.0.tar.gz
./config.sh --url https://github.com/openzim --token <your_token>

Start the runner to check it works as expected:

./run.sh

Install as a service and start:

sudo ./svc.sh install
sudo ./svc.sh start

You can then check status with:

sudo ./svc.sh status