Skip to content

Add test workflow using options field for healthcheck #1

Add test workflow using options field for healthcheck

Add test workflow using options field for healthcheck #1

name: Test Healthcheck via Options
on:
workflow_dispatch:
push:
branches:
- feature/service-container-healthcheck
jobs:
test-healthcheck-options:
runs-on: self-hosted
services:
# Test healthcheck via options field (docker run flags)
nginx:
image: nginx:alpine
# These options get passed to docker run
options: >-
--health-cmd "curl -f http://localhost:80/ || exit 1"
--health-interval 5s
--health-timeout 3s
--health-retries 3
ports:
- 8080:80
steps:
- name: Wait for service and test healthcheck
run: |
echo "Waiting for nginx to be healthy..."
for i in {1..30}; do
status=$(docker inspect --format='{{.State.Health.Status}}' $(docker ps -q -f "name=nginx") 2>/dev/null || echo "starting")
echo "Health status: $status"
if [ "$status" = "healthy" ]; then
echo "✅ Nginx is healthy!"
break
fi
sleep 1
done
# Verify it's working
curl -f http://localhost:8080/ || exit 1
echo "✅ Service responds correctly"
- name: Inspect healthcheck configuration
run: |
echo "Container healthcheck config:"
docker inspect $(docker ps -q -f "name=nginx") | grep -A 20 '"Health"'
echo ""
echo "Full container info:"
docker ps -f "name=nginx" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"