Update 4 files
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 1m1s
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 1m1s
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
|
||||
# $HOME etc expanded on remote server by bash.
|
||||
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"
|
||||
GITEA_URL="https://gitea.jde.nz"
|
||||
GITEA_TOKEN="GITEA_TOKEN"
|
||||
|
||||
@@ -5,11 +5,24 @@ source "${AGENT_PATH}/common.sh"
|
||||
_check_required_env_vars "SERVER" "SERVICE" "TEMP_DIR" \
|
||||
"GITEA_RUNNER_DIRECTORY" "ACT_RUNNER_VERSION" \
|
||||
"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}"
|
||||
|
||||
# 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"
|
||||
|
||||
echo "Installation complete for service ${SERVICE}."
|
||||
|
||||
@@ -7,20 +7,20 @@ _check_required_env_vars "SERVER" "SERVICE" \
|
||||
"GITEA_URL" "GITEA_TOKEN" "GITEA_RUNNER_NAME" "GITEA_RUNNER_LABELS" \
|
||||
"CONTAINER_NAME"
|
||||
|
||||
DOCKER_RUN_CMD="docker run -d \
|
||||
--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"
|
||||
# Stop and remove existing container if present
|
||||
_remove_container "$CONTAINER_NAME" 2>/dev/null || true
|
||||
|
||||
|
||||
if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
|
||||
echo "${DOCKER_RUN_CMD}"
|
||||
# Start the container directly to avoid quoting issues with _create_and_start_container
|
||||
if ! docker run -d \
|
||||
--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}"
|
||||
fi
|
||||
|
||||
|
||||
@@ -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}"
|
||||
_is_container_running && _die "Couldn't stop existing container"
|
||||
_is_container_exists && _die "Couldn't remove existing container"
|
||||
_is_container_running "$CONTAINER_NAME" && _die "Couldn't stop existing container"
|
||||
_is_container_exists "$CONTAINER_NAME" && _die "Couldn't remove existing container"
|
||||
|
||||
echo "Uninstallation of ${CONTAINER_NAME} complete."
|
||||
echo "Local data folder ${GITEA_RUNNER_DIRECTORY} still in place."
|
||||
|
||||
Reference in New Issue
Block a user