Update 4 files
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 1m1s

This commit is contained in:
j
2025-12-17 23:33:14 +13:00
parent 8194500a38
commit de6ad1db93
4 changed files with 33 additions and 17 deletions

View File

@@ -1,8 +1,11 @@
# Service settings specific to this server # Service settings specific to this server
# (can also override anything in the .template_info.env file in the template to make it specific to this server) # (can also override anything in the .template_info.env file in the template to make it specific to this server)
# $HOME etc expanded on remote server by bash. # $HOME etc expanded on remote server by bash.
GITEA_RUNNER_DIRECTORY="${HOME}/.gitea-runner" GITEA_RUNNER_DIRECTORY="${HOME}/.gitea-runner"
# Change this to force re-registration (e.g., after changing name/labels/token)
REGISTRATION_ID=1
ACT_RUNNER_VERSION="0.2.11" ACT_RUNNER_VERSION="0.2.11"
GITEA_URL="https://gitea.jde.nz" GITEA_URL="https://gitea.jde.nz"
GITEA_TOKEN="GITEA_TOKEN" GITEA_TOKEN="GITEA_TOKEN"

View File

@@ -5,11 +5,24 @@ source "${AGENT_PATH}/common.sh"
_check_required_env_vars "SERVER" "SERVICE" "TEMP_DIR" \ _check_required_env_vars "SERVER" "SERVICE" "TEMP_DIR" \
"GITEA_RUNNER_DIRECTORY" "ACT_RUNNER_VERSION" \ "GITEA_RUNNER_DIRECTORY" "ACT_RUNNER_VERSION" \
"GITEA_URL" "GITEA_TOKEN" "GITEA_RUNNER_NAME" "GITEA_RUNNER_LABELS" \ "GITEA_URL" "GITEA_TOKEN" "GITEA_RUNNER_NAME" "GITEA_RUNNER_LABELS" \
"CONTAINER_NAME" "CONTAINER_NAME" "REGISTRATION_ID"
mkdir -p "${GITEA_RUNNER_DIRECTORY}" || _die "Failed to create ${GITEA_RUNNER_DIRECTORY}" mkdir -p "${GITEA_RUNNER_DIRECTORY}" || _die "Failed to create ${GITEA_RUNNER_DIRECTORY}"
# Check if registration ID changed - if so, clear old registration
STORED_REG_ID_FILE="${GITEA_RUNNER_DIRECTORY}/.registration_id"
STORED_REG_ID=""
if [[ -f "$STORED_REG_ID_FILE" ]]; then
STORED_REG_ID=$(cat "$STORED_REG_ID_FILE")
fi
if [[ "$STORED_REG_ID" != "$REGISTRATION_ID" ]]; then
echo "Registration ID changed ($STORED_REG_ID -> $REGISTRATION_ID), clearing old registration..."
rm -f "${GITEA_RUNNER_DIRECTORY}/.runner"
echo "$REGISTRATION_ID" > "$STORED_REG_ID_FILE"
fi
./start.sh || _die "Failed to start" ./start.sh || _die "Failed to start"
echo "Installation complete for service ${SERVICE}." echo "Installation complete for service ${SERVICE}."

View File

@@ -7,20 +7,20 @@ _check_required_env_vars "SERVER" "SERVICE" \
"GITEA_URL" "GITEA_TOKEN" "GITEA_RUNNER_NAME" "GITEA_RUNNER_LABELS" \ "GITEA_URL" "GITEA_TOKEN" "GITEA_RUNNER_NAME" "GITEA_RUNNER_LABELS" \
"CONTAINER_NAME" "CONTAINER_NAME"
DOCKER_RUN_CMD="docker run -d \ # Stop and remove existing container if present
--restart unless-stopped \ _remove_container "$CONTAINER_NAME" 2>/dev/null || true
--name ${CONTAINER_NAME} \
-e GITEA_INSTANCE_URL=${GITEA_URL} \
-e GITEA_RUNNER_REGISTRATION_TOKEN=${GITEA_TOKEN} \
-e GITEA_RUNNER_NAME=${GITEA_RUNNER_NAME} \
-e GITEA_RUNNER_LABELS=${GITEA_RUNNER_LABELS} \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${GITEA_RUNNER_DIRECTORY}:/data \
gitea/act_runner:nightly"
# Start the container directly to avoid quoting issues with _create_and_start_container
if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then if ! docker run -d \
echo "${DOCKER_RUN_CMD}" --restart unless-stopped \
--name "${CONTAINER_NAME}" \
-e GITEA_INSTANCE_URL="${GITEA_URL}" \
-e GITEA_RUNNER_REGISTRATION_TOKEN="${GITEA_TOKEN}" \
-e GITEA_RUNNER_NAME="${GITEA_RUNNER_NAME}" \
-e GITEA_RUNNER_LABELS="${GITEA_RUNNER_LABELS}" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "${GITEA_RUNNER_DIRECTORY}:/data" \
gitea/act_runner:nightly; then
_die "Failed to start container ${CONTAINER_NAME}" _die "Failed to start container ${CONTAINER_NAME}"
fi fi

View File

@@ -7,8 +7,8 @@ _check_required_env_vars "SERVER" "SERVICE" "GITEA_RUNNER_DIRECTORY" "CONTAINER_
_remove_container "$CONTAINER_NAME" || _die "Failed to remove container ${CONTAINER_NAME}" _remove_container "$CONTAINER_NAME" || _die "Failed to remove container ${CONTAINER_NAME}"
_is_container_running && _die "Couldn't stop existing container" _is_container_running "$CONTAINER_NAME" && _die "Couldn't stop existing container"
_is_container_exists && _die "Couldn't remove existing container" _is_container_exists "$CONTAINER_NAME" && _die "Couldn't remove existing container"
echo "Uninstallation of ${CONTAINER_NAME} complete." echo "Uninstallation of ${CONTAINER_NAME} complete."
echo "Local data folder ${GITEA_RUNNER_DIRECTORY} still in place." echo "Local data folder ${GITEA_RUNNER_DIRECTORY} still in place."