Skip to content

Commit 87d8e95

Browse files
committed
Update s390x actions-runner docker
1 parent 005c2d3 commit 87d8e95

9 files changed

Lines changed: 131 additions & 332 deletions

File tree

arch/s390/README.md

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -222,56 +222,44 @@ need for constantly changing the patch.
222222
## Configuring the builder.
223223

224224
### Install prerequisites.
225-
226225
```
227226
sudo dnf install podman
228227
```
229228

230-
### Add actions-runner service.
229+
### Create a config file, needs github personal access token.
230+
Access token needs permissions; Repo Admin RW, Org Self-hosted runners RW.
231+
For details, consult
232+
https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-a-repository
231233

234+
#### Create file /etc/actions-runner:
232235
```
233-
sudo cp self-hosted-builder/actions-runner.service /etc/systemd/system/
234-
sudo systemctl daemon-reload
236+
REPO=<owner>/<name>
237+
PAT_TOKEN=<github_pat_***>
235238
```
236239

237-
### Create a config file, needs github personal access token.
238-
240+
#### Set permissions on /etc/actions-runner:
239241
```
240-
# Create file /etc/actions-runner
241-
repo=<owner>/<name>
242-
access_token=<ghp_***>
242+
chmod 600 /etc/actions-runner
243243
```
244244

245-
Access token should have the repo scope, consult
246-
https://docs.github.com/en/rest/reference/actions#create-a-registration-token-for-a-repository
247-
for details.
245+
### Add actions-runner service.
246+
```
247+
sudo cp self-hosted-builder/actions-runner.service /etc/systemd/system/
248+
sudo systemctl daemon-reload
249+
```
248250

249251
### Autostart actions-runner.
250-
251252
```
252253
$ sudo systemctl enable --now actions-runner
253254
```
254255

255-
## Rebuilding the container
256-
257-
In order to update the `gaplib-actions-runner` podman container, e.g. to get the
258-
latest OS security fixes, follow these steps:
256+
### Add auto-rebuild cronjob
257+
```
258+
sudo cp self-hosted-builder/actions-runner-rebuild.sh /etc/cron.weekly/
259+
chmod +x /etc/cron.weekly/actions-runner-rebuild.sh
259260
```
260-
# Stop actions-runner service
261-
sudo systemctl stop actions-runner
262-
263-
# Delete old container
264-
sudo podman container rm gaplib-actions-runner
265-
266-
# Delete old image
267-
sudo podman image rm localhost/zlib-ng/actions-runner
268-
269-
# Build image
270-
sudo podman build --squash -f Dockerfile.zlib-ng --tag zlib-ng/actions-runner --build-arg .
271-
272-
# Build container
273-
sudo podman create --name=gaplib-actions-runner --env-file=/etc/actions-runner --init --interactive --volume=actions-runner-temp:/home/actions-runner zlib-ng/actions-runner
274261

275-
# Start actions-runner service
276-
sudo systemctl start actions-runner
262+
## Building / Rebuilding the container
263+
```
264+
sudo /etc/cron.weekly/actions-runner-rebuild.sh
277265
```
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
#
4+
# Ephemeral runner startup script.
5+
#
6+
# Expects the following environment variables:
7+
#
8+
# - REPO=<owner>
9+
# - PAT_TOKEN=<github_pat_***>
10+
#
11+
12+
set -e -u
13+
14+
# Validate required environment variables
15+
if [ -z "${REPO:-}" ] || [ -z "${PAT_TOKEN:-}" ]; then
16+
echo "Error: REPO and/or PAT_TOKEN environment variables not found"
17+
exit 1
18+
fi
19+
20+
# Check the cached registration token.
21+
TOKEN_FILE=registration-token.json
22+
if [ -f $TOKEN_FILE ]; then
23+
set +e
24+
EXPIRES=$(jq --raw-output .EXPIRES "$TOKEN_FILE" 2>/dev/null)
25+
STATUS=$?
26+
set -e
27+
else
28+
STATUS=1
29+
fi
30+
if [[ $STATUS -ne 0 || $(date +%s) -ge $(date -d "$EXPIRES" +%s) ]]; then
31+
# Refresh the cached registration token.
32+
curl \
33+
-X POST \
34+
-H "Accept: application/vnd.github+json" \
35+
-H "Authorization: Bearer $PAT_TOKEN" \
36+
"https://api.github.com/repos/$REPO/actions/runners/registration-token" \
37+
-o "$TOKEN_FILE"
38+
fi
39+
40+
REG_TOKEN=$(jq --raw-output .token "$TOKEN_FILE")
41+
if [ $REG_TOKEN = "null" ]; then
42+
echo "Failed to get registration token"
43+
exit 1
44+
fi
45+
46+
# (Re-)register the runner.
47+
set -x
48+
./config.sh \
49+
--url "https://github.com/$REPO" \
50+
--token "$REG_TOKEN" \
51+
--unattended \
52+
--disableupdate \
53+
--replace \
54+
--labels z15 \
55+
--ephemeral
56+
57+
# Run one job.
58+
./run.sh
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/bash
2+
set -ex
3+
4+
if [ ! -f /etc/actions-runner ]; then
5+
echo "Error: /etc/actions-runner env file not found"
6+
exit 1
7+
fi
8+
9+
# Use local file if run interactively, otherwise wget the current one.
10+
if [ -t 0 ] ; then
11+
if [ ! -f actions-runner.Dockerfile ]; then
12+
echo "Error: actions-runner.Dockerfile not found"
13+
exit 1
14+
fi
15+
DOCKERFILE=actions-runner.Dockerfile
16+
else
17+
DOCKERFILE="$(mktemp)"
18+
wget https://raw.githubusercontent.com/zlib-ng/zlib-ng/refs/heads/develop/arch/s390/self-hosted-builder/actions-runner.Dockerfile -O $DOCKERFILE
19+
fi
20+
21+
# Stop service
22+
systemctl stop actions-runner
23+
24+
# Delete container
25+
podman container rm gaplib-actions-runner
26+
27+
# Delete image
28+
podman image rm localhost/zlib-ng/actions-runner
29+
30+
# Build image
31+
podman build --squash -f $DOCKERFILE --tag zlib-ng/actions-runner .
32+
33+
# Create container
34+
podman create --replace --name=gaplib-actions-runner --env-file=/etc/actions-runner --init --volume=actions-runner-temp:/home/actions-runner zlib-ng/actions-runner
35+
36+
# Start service
37+
systemctl start actions-runner
38+
39+
# Clean up tempfile
40+
if [ ! -t 0 ] ; then
41+
rm $DOCKERFILE
42+
echo "Deleted dockerfile $DOCKERFILE"
43+
fi

arch/s390/self-hosted-builder/actions-runner.Dockerfile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,21 @@
33
FROM almalinux:9
44

55
RUN dnf update -y -q && \
6-
dnf install -y -q --enablerepo=crb wget git which sudo jq \
6+
dnf install -y -q --enablerepo=crb wget git which sudo jq sed \
77
cmake make automake autoconf m4 libtool ninja-build python3-pip \
88
gcc gcc-c++ clang llvm-toolset glibc-all-langpacks langpacks-en \
99
glibc-static libstdc++-static libstdc++-devel libxslt-devel libxml2-devel
1010

11-
RUN dnf install -y -q dotnet-sdk-6.0 && \
11+
RUN dnf install -y -q dotnet-sdk-8.0 && \
1212
echo "Using SDK - `dotnet --version`"
1313

14-
COPY runner-s390x.patch /tmp/runner.patch
15-
COPY runner-global.json /tmp/global.json
16-
1714
RUN cd /tmp && \
1815
git clone -q https://github.com/actions/runner && \
1916
cd runner && \
2017
git checkout $(git describe --tags $(git rev-list --tags --max-count=1)) -b build && \
21-
git apply /tmp/runner.patch && \
22-
cp -f /tmp/global.json src/global.json
23-
18+
wget https://github.com/anup-kodlekere/gaplib/raw/refs/heads/main/build-files/runner-sdk-8.patch && \
19+
git apply runner-sdk-8.patch && \
20+
sed -i'' -e /version/s/8......\"$/$8.0.100\"/ src/global.json
2421

2522
RUN cd /tmp/runner/src && \
2623
./dev.sh layout && \
@@ -41,7 +38,8 @@ RUN rm -rf /tmp/runner /var/cache/dnf/* /tmp/runner.patch /tmp/global.json &
4138
USER actions-runner
4239

4340
# Scripts.
44-
COPY fs/ /
41+
COPY entrypoint /usr/bin/
42+
COPY actions-runner /usr/bin/
4543
WORKDIR /home/actions-runner
4644
ENTRYPOINT ["/usr/bin/entrypoint"]
4745
CMD ["/usr/bin/actions-runner"]

arch/s390/self-hosted-builder/actions-runner.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Environment=PODMAN_SYSTEMD_UNIT=%n
1010
Restart=always
1111
TimeoutStopSec=61
1212
ExecStart=/usr/bin/podman start gaplib-actions-runner
13-
ExecStop=/usr/bin/podman stop -t 1 gaplib-actions-runner
14-
ExecStopPost=/usr/bin/podman stop -t 1 gaplib-actions-runner
13+
ExecStop=/usr/bin/podman stop -t 30 gaplib-actions-runner
14+
ExecStopPost=/usr/bin/podman stop -t 10 gaplib-actions-runner
1515
Type=forking
1616

1717
[Install]
File renamed without changes.

arch/s390/self-hosted-builder/fs/usr/bin/actions-runner

Lines changed: 0 additions & 40 deletions
This file was deleted.

arch/s390/self-hosted-builder/runner-global.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)