Asteria Qt CI / rebuild-images (linux-x86_64) (push) Skipped
Asteria Qt CI / rebuild-images (windows-arm64) (push) Skipped
Asteria Qt CI / rebuild-images (windows-x86_64) (push) Skipped
Asteria Qt CI / build-linux (push) Canceled after 0s
Asteria Qt CI / build-linux-arm64 (push) Canceled after 0s
Asteria Qt CI / build-windows (push) Canceled after 0s
Asteria Qt CI / build-windows-arm64 (push) Canceled after 0s
Asteria Qt CI / build-macos (push) Canceled after 0s
Asteria Qt CI / test-linux (push) Canceled after 0s
Asteria Qt CI / test-macos (push) Canceled after 0s
Asteria Qt CI / package-linux (push) Canceled after 0s
Asteria Qt CI / package-linux-arm64 (push) Canceled after 0s
Asteria Qt CI / rebuild-images (linux-arm64) (push) Skipped
Asteria Qt CI / package-windows (push) Canceled after 0s
Asteria Qt CI / package-windows-arm64 (push) Canceled after 0s
Asteria Qt CI / package-macos (push) Canceled after 0s
Asteria Qt CI / release (push) Canceled after 0s
92 lines
2.6 KiB
Bash
Executable File
92 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
DATA_DIR="${GITEA_RUNNER_DATA_DIR:-/data}"
|
|
WORKDIR_PARENT="${GITEA_RUNNER_WORKDIR:-/builds}"
|
|
CONFIG_FILE="${DATA_DIR}/config.yaml"
|
|
RUNNER_FILE="${DATA_DIR}/.runner"
|
|
|
|
INSTANCE_URL="${GITEA_INSTANCE_URL:-${CI_SERVER_URL:-}}"
|
|
REG_TOKEN="${GITEA_RUNNER_REGISTRATION_TOKEN:-${RUNNER_TOKEN:-${REGISTRATION_TOKEN:-}}}"
|
|
RUNNER_NAME="${GITEA_RUNNER_NAME:-${RUNNER_NAME:-asteria-qt-runner}}"
|
|
RAW_LABELS="${GITEA_RUNNER_LABELS:-${RUNNER_TAGS:-}}"
|
|
CAPACITY="${GITEA_RUNNER_CAPACITY:-1}"
|
|
INSECURE="${GITEA_RUNNER_INSECURE:-false}"
|
|
|
|
mkdir -p "${DATA_DIR}" "${WORKDIR_PARENT}"
|
|
cd "${DATA_DIR}"
|
|
|
|
# Normalize labels: append ':host' when no executor suffix is specified so jobs
|
|
# run directly inside this container's pre-installed toolchain.
|
|
NORMALIZED_LABELS=()
|
|
if [ -n "${RAW_LABELS}" ]; then
|
|
IFS=',' read -ra _parts <<< "${RAW_LABELS}"
|
|
for lbl in "${_parts[@]}"; do
|
|
lbl="$(printf '%s' "${lbl}" | sed -E 's/^[[:space:]]+//; s/[[:space:]]+$//')"
|
|
[ -z "${lbl}" ] && continue
|
|
if [[ "${lbl}" != *:* ]]; then
|
|
lbl="${lbl}:host"
|
|
fi
|
|
NORMALIZED_LABELS+=("${lbl}")
|
|
done
|
|
fi
|
|
|
|
if [ ${#NORMALIZED_LABELS[@]} -eq 0 ]; then
|
|
NORMALIZED_LABELS=("linux-x86_64:host")
|
|
fi
|
|
|
|
LABELS_CSV="$(IFS=','; echo "${NORMALIZED_LABELS[*]}")"
|
|
|
|
# Always regenerate config.yaml from current environment variables
|
|
{
|
|
cat <<EOF
|
|
log:
|
|
level: info
|
|
|
|
runner:
|
|
file: ${RUNNER_FILE}
|
|
capacity: ${CAPACITY}
|
|
timeout: 3h
|
|
insecure: ${INSECURE}
|
|
fetch_timeout: 5s
|
|
fetch_interval: 2s
|
|
labels:
|
|
EOF
|
|
for lbl in "${NORMALIZED_LABELS[@]}"; do
|
|
printf ' - "%s"\n' "${lbl}"
|
|
done
|
|
cat <<EOF
|
|
|
|
cache:
|
|
enabled: true
|
|
dir: ${DATA_DIR}/cache
|
|
|
|
container:
|
|
network: ""
|
|
valid_volumes: []
|
|
|
|
host:
|
|
workdir_parent: ${WORKDIR_PARENT}
|
|
EOF
|
|
} > "${CONFIG_FILE}"
|
|
|
|
# Auto-register on first boot if .runner registration state does not exist
|
|
if [ ! -f "${RUNNER_FILE}" ]; then
|
|
if [ -z "${INSTANCE_URL}" ] || [ -z "${REG_TOKEN}" ]; then
|
|
echo "ERROR: ${RUNNER_FILE} not found and GITEA_INSTANCE_URL / GITEA_RUNNER_REGISTRATION_TOKEN are not set." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Registering Gitea runner '${RUNNER_NAME}' at '${INSTANCE_URL}' with labels '${LABELS_CSV}'..."
|
|
act_runner register \
|
|
--no-interactive \
|
|
--config "${CONFIG_FILE}" \
|
|
--instance "${INSTANCE_URL}" \
|
|
--token "${REG_TOKEN}" \
|
|
--name "${RUNNER_NAME}" \
|
|
--labels "${LABELS_CSV}"
|
|
fi
|
|
|
|
echo "Starting Gitea act_runner daemon (name=${RUNNER_NAME}, labels=${LABELS_CSV})..."
|
|
exec act_runner daemon --config "${CONFIG_FILE}"
|