diff --git a/README.md b/README.md index 52a5dec..209d4ac 100644 --- a/README.md +++ b/README.md @@ -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|``|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 diff --git a/image/Dockerfile b/image/Dockerfile index f0921d9..45ba17c 100644 --- a/image/Dockerfile +++ b/image/Dockerfile @@ -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 diff --git a/image/run_runner.sh b/image/run_runner.sh index f7605e4..376ed0a 100644 --- a/image/run_runner.sh +++ b/image/run_runner.sh @@ -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