chore: harden production deploy scripts

This commit is contained in:
2026-05-27 22:14:19 +08:00
parent 0c30fb9091
commit b6a7e7b4b8
2 changed files with 32 additions and 6 deletions

View File

@@ -13,12 +13,27 @@ ssh "$HOST" "cd '$APP_DIR' && \
echo \"ERROR: local API/dev URL leaked into web static bundle\" >&2
exit 1
fi
for p in / /login/ /_next/does-not-exist.js /api/health; do
code=\$(curl -sS -o /tmp/skg-smoke.out -w \"%{http_code}\" \"http://127.0.0.1\$p\")
case \"\$p:\$code\" in
/:302|/login/:200|/_next/does-not-exist.js:404|/api/health:401) echo \"web:\$p \$code\" ;;
*) echo \"ERROR: unexpected web route status \$p \$code\" >&2; head -c 200 /tmp/skg-smoke.out >&2; exit 1 ;;
esac
check_route() {
p=\"\$1\"
expected=\"\$2\"
attempts=\"\${3:-30}\"
i=1
while [ \"\$i\" -le \"\$attempts\" ]; do
code=\$(curl -sS -o /tmp/skg-smoke.out -w \"%{http_code}\" \"http://127.0.0.1\$p\" || echo 000)
if [ \"\$code\" = \"\$expected\" ]; then
echo \"web:\$p \$code\"
return 0
fi
sleep 1
i=\$((i + 1))
done
echo \"ERROR: unexpected web route status \$p \$code\" >&2
head -c 200 /tmp/skg-smoke.out >&2 || true
exit 1
}
for route in \"/ 302\" \"/login/ 200\" \"/_next/does-not-exist.js 404\" \"/api/health 401\"; do
set -- \$route
check_route \"\$1\" \"\$2\"
done
' && \
docker exec skg-marketing-api sh -lc '