feat: leverage healthcheck for container status
Blog Test / Check-Rebuild (push) Successful in 6s
Blog Test / Build (push) Skipped
Blog Test / Deploy-Test (push) Skipped
Blog Test / Test (push) Skipped

This commit is contained in:
2026-09-16 09:20:27 +00:00
parent 246ba7bf07
commit 7172e7b7a9
2 changed files with 141 additions and 7 deletions
+49 -3
View File
@@ -107,12 +107,58 @@ jobs:
- name: Launch Blog Test Deployment
run: |
cd /blog
docker compose down ${CONTAINER_NAME}
BLOG_TEST_BRANCH=${{ gitea.ref_name }} docker compose up -d ${CONTAINER_NAME}
sleep 30
echo "- Stopping existing ${CONTAINER_NAME}..."
docker compose down ${CONTAINER_NAME}
echo "- Starting ${CONTAINER_NAME}..."
BLOG_TEST_BRANCH=${{ gitea.ref_name }} \
docker compose up -d ${CONTAINER_NAME}
echo "- Waiting for ${CONTAINER_NAME} to become healthy..."
timeout=300
elapsed=0
while true; do
status=$(docker inspect \
--format='{{.State.Health.Status}}' \
${CONTAINER_NAME})
echo "Health status: ${status}"
case "$status" in
healthy)
echo "✅ ${CONTAINER_NAME} is healthy"
break
;;
unhealthy)
echo "❌ ${CONTAINER_NAME} is unhealthy"
echo "- Displaying container logs"
docker compose logs ${CONTAINER_NAME}
exit 1
;;
*)
;;
esac
if [ "$elapsed" -ge "$timeout" ]; then
echo "❌ Timed out waiting for ${CONTAINER_NAME}"
echo "- Displaying container logs"
docker compose logs ${CONTAINER_NAME}
exit 1
fi
sleep 2
elapsed=$((elapsed + 2))
done
echo "- Displaying container logs"
docker compose logs ${CONTAINER_NAME}
Test:
needs: Deploy-Test
runs-on: ubuntu