feat: support GITEA_RUNNER_EPHEMERAL

This commit is contained in:
sebthom 2025-09-01 16:22:10 +02:00
parent 457b67892c
commit 5edd7949b1
3 changed files with 6 additions and 0 deletions

View File

@ -260,6 +260,7 @@ Name|Default Value|Description
----|-------------|-----------
GITEA_INSTANCE_INSECURE|`false`|If `true` don't verify the TLS certificate of the Gitea instance
GITEA_RUNNER_NAME|`<empty>`|If not specified the container's hostname is used
GITEA_RUNNER_EPHEMERAL|`false`|If `true` or `1`, the runner will exit after completing a single job
GITEA_RUNNER_REGISTRATION_FILE|`/data/.runner`|The JSON file that holds the result from the runner registration with the Gitea instance
GITEA_RUNNER_REGISTRATION_TIMEOUT|`30`|In case of failure, registration is retried until this timeout in seconds is reached
GITEA_RUNNER_REGISTRATION_RETRY_INTERVAL|`5`|Wait period in seconds between registration retries

View File

@ -213,6 +213,7 @@ ubuntu-20.04:docker://ghcr.io/catthehacker/ubuntu:act-20.04' \
GITEA_RUNNER_UID=1000 \
GITEA_RUNNER_GID=1000 \
#
GITEA_RUNNER_EPHEMERAL=false \
GITEA_RUNNER_REGISTRATION_TIMEOUT=30\
GITEA_RUNNER_REGISTRATION_RETRY_INTERVAL=5s

View File

@ -63,6 +63,9 @@ if [[ ! -s ${GITEA_RUNNER_REGISTRATION_FILE:-.runner} ]]; then
log INFO " GITEA_RUNNER_NAME=$GITEA_RUNNER_NAME"
log INFO " GITEA_RUNNER_REGISTRATION_TOKEN=${GITEA_RUNNER_REGISTRATION_TOKEN//?/*}"
log INFO " GITEA_RUNNER_LABELS=$GITEA_RUNNER_LABELS"
if [[ $GITEA_RUNNER_EPHEMERAL == "true" || $GITEA_RUNNER_EPHEMERAL == "1" ]]; then
log INFO " GITEA_RUNNER_EPHEMERAL=$GITEA_RUNNER_EPHEMERAL (runner will exit after completing one job)"
fi
wait_until=$(( $(date +%s) + GITEA_RUNNER_REGISTRATION_TIMEOUT ))
while true; do
if act_runner register \
@ -71,6 +74,7 @@ if [[ ! -s ${GITEA_RUNNER_REGISTRATION_FILE:-.runner} ]]; then
--name "$GITEA_RUNNER_NAME" \
--labels "$GITEA_RUNNER_LABELS" \
--config "$effective_config_file" \
"$([[ $GITEA_RUNNER_EPHEMERAL == "true" || $GITEA_RUNNER_EPHEMERAL == "1" ]] && echo --ephemeral)" \
--no-interactive; then
break;
fi