Files
forgerunner/scripts/register-runner.sh
T

37 lines
1.4 KiB
Bash
Raw Normal View History

2026-06-29 21:56:12 -05:00
#!/usr/bin/env bash
# register-runner.sh — standalone registration helper (run outside container)
# Useful for pre-generating config before first container start.
set -euo pipefail
: "${GITEA_INSTANCE_URL:?GITEA_INSTANCE_URL must be set}"
: "${GITEA_RUNNER_TOKEN:?GITEA_RUNNER_TOKEN must be set}"
: "${GITEA_RUNNER_NAME:?GITEA_RUNNER_NAME must be set}"
RUNNER_CONFIG_PATH="${RUNNER_CONFIG_PATH:-./config/runner.yaml}"
GITEA_RUNNER_LABELS="${GITEA_RUNNER_LABELS:-ubuntu-latest:docker://node:20-bullseye}"
echo "Registering runner: ${GITEA_RUNNER_NAME}"
echo " Instance : ${GITEA_INSTANCE_URL}"
echo " Config : ${RUNNER_CONFIG_PATH}"
echo " Labels : ${GITEA_RUNNER_LABELS}"
mkdir -p "$(dirname "${RUNNER_CONFIG_PATH}")"
docker run --rm \
-v "$(pwd)/config:/config" \
-e GITEA_INSTANCE_URL="${GITEA_INSTANCE_URL}" \
-e GITEA_RUNNER_TOKEN="${GITEA_RUNNER_TOKEN}" \
-e GITEA_RUNNER_NAME="${GITEA_RUNNER_NAME}" \
-e GITEA_RUNNER_LABELS="${GITEA_RUNNER_LABELS}" \
-e RUNNER_CONFIG_PATH="/config/runner.yaml" \
custom-gitea-runner:latest \
act_runner register \
--config /config/runner.yaml \
--instance "${GITEA_INSTANCE_URL}" \
--token "${GITEA_RUNNER_TOKEN}" \
--name "${GITEA_RUNNER_NAME}" \
--labels "${GITEA_RUNNER_LABELS}" \
--no-interactive
echo "Registration complete. Config written to ${RUNNER_CONFIG_PATH}."