Skip to content

Commit

Permalink
release 1.2.0
Browse files Browse the repository at this point in the history
* updated the github actions runner version to 2.3.19.1 to support
  GHE series 3.14
* read env settings in the delete-offline-runners.sh script
* added -k to curl commands in delete-offline-runners.sh to
  workaround ssl wildcard insecure messages
* improved VM setup instructions in the readme
  • Loading branch information
tombradford committed Sep 11, 2024
1 parent 11c2239 commit dfdeba3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 25 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# GitHub Actions Runner Docker Changelog

## 1.2.0

* updated the github actions runner version to 2.3.19.1 to support
GHE series 3.14
* read env settings in the delete-offline-runners.sh script
* added -k to curl commands in delete-offline-runners.sh to
workaround ssl wildcard insecure messages
* improved VM setup instructions in the readme

## 1.1.1

* Added quotes around cpus field in `compose.yml` to fix a docker
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM rockylinux:9.3

ARG RUNNER_VERSION="2.314.1"
ARG RUNNER_VERSION="2.319.1"

# Prevents installdependencies.sh from prompting the user and blocking the image creation
RUN useradd -m docker
Expand Down
39 changes: 24 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,51 @@ self-hosted runner.
## VM setup

1. create a Rocky 9 VM from a VM template
2. install docker and jq:

2. install docker and jq (as root):

```
dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
dnf install docker-ce docker-ce-cli containerd.io jq
```

3. create the local user `gherunner`
4. add the `gherunner` user to the `docker` group:
3. create the local user `gherunner` (as root):

```
usermod -G docker gherunner
useradd -m gherunner
```

5. as the `gherunner` user, download the latest release of this repo in
a writable location
6. set the `GITHUB`, `TARGET` and `TOKEN` settings as appropriate in the
`ghe-actions-docker.env` file (further information and examples are
provided in this file).

7. start and enable the docker service:
4. start and enable the docker service (as root):

```
systemctl start docker
systemctl enable docker
```

5. add the `gherunner` user to the `docker` group (as root):

```
usermod -G docker gherunner
```

6. as the `gherunner` user, download the latest release of this repo in
a writable location (i.e. `/home/gherunner`)

7. set the `GITHUB`, `TARGET` and `TOKEN` settings as appropriate in the
`ghe-actions-docker.env` file (further information and examples are
provided in this file).

## Build

To build the container image:
To build the container image (as the `gherunner` user):

```
docker build --tag ghe-actions-runner .
```

## Run

To run the container image:
To run the container image (as the `gherunner` user):

```
docker compose up --scale runner=X -d
Expand All @@ -71,8 +78,10 @@ where `X` is the number of runners.

Runners should automatically clean up after themselves once stopped, but if
a SIGKILL occurs, a container may get stuck in the "Offline" state. Should
this happen, run the `./delete-offline-runners.sh` script with the required
arguments.
this happen, run the `./delete-offline-runners.sh` script.

This script reads the `GITHUB`, `TARGET` and `TOKEN` settings from the
`ghe-actions-docker.env` file .

## Useful commands

Expand Down
13 changes: 4 additions & 9 deletions delete-offline-runners.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#!/bin/bash

GITHUB=$1
TARGET=$2
TOKEN=$3
set -e

if [[ "$#" -ne 3 ]]; then
echo "Usage: $0 GITHUB_URL TARGET TOKEN"
exit
fi
source ghe-actions-docker.env

# test if the target is a repo, prepend /repos for the api
curl --fail --silent -k -X GET -H "Authorization: token ${TOKEN}" -H "Accept: application/vnd.github+json" \
Expand All @@ -24,7 +19,7 @@ fi

echo "Removing offline GH actions runners on https://${GITHUB}/${TARGET}..."

RUNNER_LIST=$(curl -H "Authorization: token ${TOKEN}" -H "Accept: application/vnd.github+json" \
RUNNER_LIST=$(curl -k -H "Authorization: token ${TOKEN}" -H "Accept: application/vnd.github+json" \
https://api.${GITHUB}/${API_TARGET}/actions/runners \
| jq '[.runners[] | select(.status | contains("offline")) | {id: .id}]')

Expand All @@ -34,7 +29,7 @@ for id in $(echo "$RUNNER_LIST" | jq -r '.[] | @base64'); do
echo ${id} | base64 --decode | jq -r ${1}
}
echo "Deleting $(_jq '.id')"
curl -X DELETE -H "Accept: application/vnd.github+json" \
curl -k -X DELETE -H "Accept: application/vnd.github+json" \
-H "Authorization: token ${TOKEN}" \
https://api.${GITHUB}/${API_TARGET}/actions/runners/$(_jq '.id')
done

0 comments on commit dfdeba3

Please sign in to comment.