fix(ci): auto-detect stand for ci-reports URL on IFT runner

Remove hardcoded dev CI_REPORTS_BASE_URL/RUNNER_STAND from workflow.
detect_stand() picks ift/stage/dev from host paths and swarm services.

[skip ci]
This commit is contained in:
2026-07-28 10:13:38 +03:00
parent 5ed361d8ff
commit 7bd6e52d18
2 changed files with 29 additions and 11 deletions
-2
View File
@@ -30,8 +30,6 @@ env:
BUILDKIT_PROGRESS: quiet
DOCKER_BUILDKIT: 1
REGISTRY: git.sabilin.com/eventhub
CI_REPORTS_BASE_URL: https://ci-reports.dev.eventhub.local
RUNNER_STAND: dev
jobs:
test:
+29 -9
View File
@@ -20,13 +20,30 @@ detect_stand() {
echo "${RUNNER_STAND}"
return 0
fi
# Gitea runner на dev-машине: отчёты в /var/eventhub/ci-reports локально.
# Наличие /opt/eventhub-ift (SSH deploy) не означает, что HTML лежит на IFT-сервере.
if [[ -f /opt/eventhub-ift/.env ]] || [[ -d /opt/eventhub-ift ]]; then
echo "ift"
return 0
fi
if [[ -f /opt/eventhub-stage/.env ]] || [[ -d /opt/eventhub-stage ]]; then
echo "stage"
return 0
fi
if command -v docker >/dev/null 2>&1 \
&& docker service ls --format '{{.Name}}' 2>/dev/null | grep -qx 'eventhub-ift-core_ci-reports'; then
echo "ift"
return 0
fi
if command -v docker >/dev/null 2>&1 \
&& docker service ls --format '{{.Name}}' 2>/dev/null | grep -qx 'eventhub_ci-reports'; then
echo "dev"
return 0
fi
echo "dev"
}
if [[ -n "${CI_REPORTS_BASE_URL:-}" ]]; then
BASE_URL="${CI_REPORTS_BASE_URL%/}"
STAND="${RUNNER_STAND:-custom}"
else
STAND="$(detect_stand)"
BASE_URL="https://ci-reports.${STAND}.eventhub.local"
@@ -57,13 +74,15 @@ ensure_ci_reports_dir
ensure_ci_reports_nginx() {
command -v docker >/dev/null 2>&1 || return 0
local svc replicas
svc=$(docker service ls --format '{{.Name}}' 2>/dev/null | grep -E '^eventhub_ci-reports$' | head -n 1 || true)
[[ -n "${svc}" ]] || return 0
replicas=$(docker service ls --format '{{.Name}} {{.Replicas}}' 2>/dev/null | awk '$1=="eventhub_ci-reports"{print $2; exit}')
if [[ "${replicas}" == 0/* ]] || [[ -z "${replicas}" ]]; then
echo "Starting ${svc}=1 (dev ci-reports nginx)..."
docker service scale "${svc}=1" 2>/dev/null || true
fi
for svc in eventhub-ift-core_ci-reports eventhub_ci-reports; do
docker service ls --format '{{.Name}}' 2>/dev/null | grep -qx "${svc}" || continue
replicas=$(docker service ls --format '{{.Name}} {{.Replicas}}' 2>/dev/null | awk -v s="${svc}" '$1==s{print $2; exit}')
if [[ "${replicas}" == 0/* ]] || [[ -z "${replicas}" ]]; then
echo "Starting ${svc}=1 (ci-reports nginx)..."
docker service scale "${svc}=1" 2>/dev/null || true
fi
return 0
done
}
ensure_ci_reports_nginx
@@ -114,6 +133,7 @@ INDEX="${REPORTS_DIR}/${REPO}/${RUN_ID}/index.html"
URL="${BASE_URL}/${REPO}/${RUN_ID}/${KIND}/"
INDEX_URL="${BASE_URL}/${REPO}/${RUN_ID}/"
echo "Report stand: ${STAND}"
echo "Report: ${URL}"
echo "Report index: ${INDEX_URL}"
echo "Report path: ${DEST}"