-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
131 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Ephemeral runner startup script. | ||
# | ||
# Expects the following environment variables: | ||
# | ||
# - REPO=<owner> | ||
# - PAT_TOKEN=<github_pat_***> | ||
# | ||
|
||
set -e -u | ||
|
||
# Validate required environment variables | ||
if [ -z "${REPO:-}" ] || [ -z "${PAT_TOKEN:-}" ]; then | ||
echo "Error: REPO and/or PAT_TOKEN environment variables not found" | ||
exit 1 | ||
fi | ||
|
||
# Check the cached registration token. | ||
TOKEN_FILE=registration-token.json | ||
if [ -f $TOKEN_FILE ]; then | ||
set +e | ||
EXPIRES=$(jq --raw-output .EXPIRES "$TOKEN_FILE" 2>/dev/null) | ||
STATUS=$? | ||
set -e | ||
else | ||
STATUS=1 | ||
fi | ||
if [[ $STATUS -ne 0 || $(date +%s) -ge $(date -d "$EXPIRES" +%s) ]]; then | ||
# Refresh the cached registration token. | ||
curl \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer $PAT_TOKEN" \ | ||
"https://api.github.com/repos/$REPO/actions/runners/registration-token" \ | ||
-o "$TOKEN_FILE" | ||
fi | ||
|
||
REG_TOKEN=$(jq --raw-output .token "$TOKEN_FILE") | ||
if [ $REG_TOKEN = "null" ]; then | ||
echo "Failed to get registration token" | ||
exit 1 | ||
fi | ||
|
||
# (Re-)register the runner. | ||
set -x | ||
./config.sh \ | ||
--url "https://github.com/$REPO" \ | ||
--token "$REG_TOKEN" \ | ||
--unattended \ | ||
--disableupdate \ | ||
--replace \ | ||
--labels z15 \ | ||
--ephemeral | ||
|
||
# Run one job. | ||
./run.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/bash | ||
set -ex | ||
|
||
if [ ! -f /etc/actions-runner ]; then | ||
echo "Error: /etc/actions-runner env file not found" | ||
exit 1 | ||
fi | ||
|
||
# Use local file if run interactively, otherwise wget the current one. | ||
if [ -t 0 ] ; then | ||
if [ ! -f actions-runner.Dockerfile ]; then | ||
echo "Error: actions-runner.Dockerfile not found" | ||
exit 1 | ||
fi | ||
DOCKERFILE=actions-runner.Dockerfile | ||
else | ||
DOCKERFILE="$(mktemp)" | ||
wget https://raw.githubusercontent.com/zlib-ng/zlib-ng/refs/heads/develop/arch/s390/self-hosted-builder/actions-runner.Dockerfile -O $DOCKERFILE | ||
fi | ||
|
||
# Stop service | ||
systemctl stop actions-runner | ||
|
||
# Delete container | ||
podman container rm gaplib-actions-runner | ||
|
||
# Delete image | ||
podman image rm localhost/zlib-ng/actions-runner | ||
|
||
# Build image | ||
podman build --squash -f $DOCKERFILE --tag zlib-ng/actions-runner . | ||
|
||
# Create container | ||
podman create --replace --name=gaplib-actions-runner --env-file=/etc/actions-runner --init --volume=actions-runner-temp:/home/actions-runner zlib-ng/actions-runner | ||
|
||
# Start service | ||
systemctl start actions-runner | ||
|
||
# Clean up tempfile | ||
if [ ! -t 0 ] ; then | ||
rm $DOCKERFILE | ||
echo "Deleted dockerfile $DOCKERFILE" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.