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:
@@ -30,8 +30,6 @@ env:
|
|||||||
BUILDKIT_PROGRESS: quiet
|
BUILDKIT_PROGRESS: quiet
|
||||||
DOCKER_BUILDKIT: 1
|
DOCKER_BUILDKIT: 1
|
||||||
REGISTRY: git.sabilin.com/eventhub
|
REGISTRY: git.sabilin.com/eventhub
|
||||||
CI_REPORTS_BASE_URL: https://ci-reports.dev.eventhub.local
|
|
||||||
RUNNER_STAND: dev
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
|||||||
@@ -20,13 +20,30 @@ detect_stand() {
|
|||||||
echo "${RUNNER_STAND}"
|
echo "${RUNNER_STAND}"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
# Gitea runner на dev-машине: отчёты в /var/eventhub/ci-reports локально.
|
if [[ -f /opt/eventhub-ift/.env ]] || [[ -d /opt/eventhub-ift ]]; then
|
||||||
# Наличие /opt/eventhub-ift (SSH deploy) не означает, что HTML лежит на IFT-сервере.
|
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"
|
echo "dev"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -n "${CI_REPORTS_BASE_URL:-}" ]]; then
|
if [[ -n "${CI_REPORTS_BASE_URL:-}" ]]; then
|
||||||
BASE_URL="${CI_REPORTS_BASE_URL%/}"
|
BASE_URL="${CI_REPORTS_BASE_URL%/}"
|
||||||
|
STAND="${RUNNER_STAND:-custom}"
|
||||||
else
|
else
|
||||||
STAND="$(detect_stand)"
|
STAND="$(detect_stand)"
|
||||||
BASE_URL="https://ci-reports.${STAND}.eventhub.local"
|
BASE_URL="https://ci-reports.${STAND}.eventhub.local"
|
||||||
@@ -57,13 +74,15 @@ ensure_ci_reports_dir
|
|||||||
ensure_ci_reports_nginx() {
|
ensure_ci_reports_nginx() {
|
||||||
command -v docker >/dev/null 2>&1 || return 0
|
command -v docker >/dev/null 2>&1 || return 0
|
||||||
local svc replicas
|
local svc replicas
|
||||||
svc=$(docker service ls --format '{{.Name}}' 2>/dev/null | grep -E '^eventhub_ci-reports$' | head -n 1 || true)
|
for svc in eventhub-ift-core_ci-reports eventhub_ci-reports; do
|
||||||
[[ -n "${svc}" ]] || return 0
|
docker service ls --format '{{.Name}}' 2>/dev/null | grep -qx "${svc}" || continue
|
||||||
replicas=$(docker service ls --format '{{.Name}} {{.Replicas}}' 2>/dev/null | awk '$1=="eventhub_ci-reports"{print $2; exit}')
|
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
|
if [[ "${replicas}" == 0/* ]] || [[ -z "${replicas}" ]]; then
|
||||||
echo "Starting ${svc}=1 (dev ci-reports nginx)..."
|
echo "Starting ${svc}=1 (ci-reports nginx)..."
|
||||||
docker service scale "${svc}=1" 2>/dev/null || true
|
docker service scale "${svc}=1" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
|
done
|
||||||
}
|
}
|
||||||
ensure_ci_reports_nginx
|
ensure_ci_reports_nginx
|
||||||
|
|
||||||
@@ -114,6 +133,7 @@ INDEX="${REPORTS_DIR}/${REPO}/${RUN_ID}/index.html"
|
|||||||
|
|
||||||
URL="${BASE_URL}/${REPO}/${RUN_ID}/${KIND}/"
|
URL="${BASE_URL}/${REPO}/${RUN_ID}/${KIND}/"
|
||||||
INDEX_URL="${BASE_URL}/${REPO}/${RUN_ID}/"
|
INDEX_URL="${BASE_URL}/${REPO}/${RUN_ID}/"
|
||||||
|
echo "Report stand: ${STAND}"
|
||||||
echo "Report: ${URL}"
|
echo "Report: ${URL}"
|
||||||
echo "Report index: ${INDEX_URL}"
|
echo "Report index: ${INDEX_URL}"
|
||||||
echo "Report path: ${DEST}"
|
echo "Report path: ${DEST}"
|
||||||
|
|||||||
Reference in New Issue
Block a user