Files
dropshell-templates/gitea-runner-docker/start.sh
j de6ad1db93
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 1m1s
Update 4 files
2025-12-17 23:33:14 +13:00

33 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "SERVER" "SERVICE" \
"GITEA_RUNNER_DIRECTORY" "ACT_RUNNER_VERSION" \
"GITEA_URL" "GITEA_TOKEN" "GITEA_RUNNER_NAME" "GITEA_RUNNER_LABELS" \
"CONTAINER_NAME"
# Stop and remove existing container if present
_remove_container "$CONTAINER_NAME" 2>/dev/null || true
# 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
# Check if the container is running
if ! _is_container_running "$CONTAINER_NAME"; then
_die "Container ${CONTAINER_NAME} is not running"
fi
echo "Container ${CONTAINER_NAME} started"