xpeditis2.0/scripts/ci/health-check.sh
2026-09-23 08:57:58 +02:00

14 lines
517 B
Bash

#!/usr/bin/env bash
set -euo pipefail
url="${1:?A health-check URL is required}"
[[ "$url" == https://* ]] || { echo 'Health check requires HTTPS'; exit 1; }
for attempt in {1..12}; do
status=$(curl --silent --show-error --output /dev/null --write-out '%{http_code}' \
--connect-timeout 5 --max-time 10 "$url") || status=000
echo "Health check attempt $attempt: HTTP $status"
if [[ "$status" == 200 ]]; then exit 0; fi
sleep 10
done
echo '::error::Service did not become healthy after deployment.'
exit 1