summaryrefslogtreecommitdiff
path: root/arch/s390/self-hosted-builder/actions-runner-rebuild.sh
blob: 0fcd67d4ec4c3295986b88d508b26d005e7ae6da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/bash
set -ex

TMPDIR="$(mktemp -d)"

if [ -f actions-runner.Dockerfile ]; then
    MODE=1
    cp actions-runner.Dockerfile actions-runner entrypoint $TMPDIR
    cd $TMPDIR
else
    MODE=2
    cd $TMPDIR
    wget https://raw.githubusercontent.com/zlib-ng/zlib-ng/refs/heads/develop/arch/s390/self-hosted-builder/actions-runner.Dockerfile
    wget https://raw.githubusercontent.com/zlib-ng/zlib-ng/refs/heads/develop/arch/s390/self-hosted-builder/actions-runner
    wget https://raw.githubusercontent.com/zlib-ng/zlib-ng/refs/heads/develop/arch/s390/self-hosted-builder/entrypoint
fi

# Stop service
systemctl stop actions-runner || true

# Delete old container
podman container rm gaplib-actions-runner || true

# Delete old image
podman image rm localhost/zlib-ng/actions-runner || true

# Build new image
podman build --squash -f actions-runner.Dockerfile --tag zlib-ng/actions-runner . 2>&1 | tee /var/log/actions-runner-build.log

# Create new container
podman create --replace --name=gaplib-actions-runner --env-file=/etc/actions-runner --init \
       zlib-ng/actions-runner 2>&1 | tee -a /var/log/actions-runner-build.log

# Start service
systemctl start actions-runner || true

# Cleanup
podman image prune -af || true

# Clean up tempfile
if [ "$MODE" == "2" ] ; then
    cd $TMPDIR
    rm actions-runner.Dockerfile
    rm actions-runner
    rm entrypoint
    cd ..
    rmdir $TMPDIR
    echo "Deleted tempfiles."
fi