ci: robust health check with retries; normalize IMAGE_NAME in publish workflow
This commit is contained in:
29
.github/workflows/docker-build.yml
vendored
29
.github/workflows/docker-build.yml
vendored
@@ -197,21 +197,22 @@ jobs:
|
||||
-p 8080:8080 \
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }}
|
||||
|
||||
# Step 4: Wait for it to start
|
||||
- name: ⏳ Wait for container to be ready
|
||||
run: sleep 10
|
||||
|
||||
# Step 5: Check if the health endpoint works
|
||||
- name: 🏥 Test health endpoint
|
||||
# Step 4/5: Wait and check health with retries
|
||||
- name: 🏥 Test health endpoint (retries)
|
||||
run: |
|
||||
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/api/v1/health)
|
||||
if [ $response -eq 200 ]; then
|
||||
echo "✅ Health check passed!"
|
||||
else
|
||||
echo "❌ Health check failed with status $response"
|
||||
docker logs test-container
|
||||
exit 1
|
||||
fi
|
||||
set +e
|
||||
for i in $(seq 1 30); do
|
||||
code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/api/v1/health || echo "000")
|
||||
if [ "$code" = "200" ]; then
|
||||
echo "✅ Health check passed on attempt $i"
|
||||
exit 0
|
||||
fi
|
||||
echo "Attempt $i/30: health not ready (code=$code); waiting..."
|
||||
sleep 2
|
||||
done
|
||||
echo "❌ Health check failed after retries"
|
||||
docker logs test-container || true
|
||||
exit 1
|
||||
|
||||
# Step 6: Check the logs for errors
|
||||
- name: 📋 Check container logs
|
||||
|
||||
5
.github/workflows/docker-publish.yml
vendored
5
.github/workflows/docker-publish.yml
vendored
@@ -29,6 +29,11 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
|
||||
|
||||
- name: Normalize image name
|
||||
run: |
|
||||
raw="${{ github.repository_owner }}/${{ github.event.repository.name }}"
|
||||
echo "IMAGE_NAME=$(echo "$raw" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
|
||||
|
||||
|
||||
Reference in New Issue
Block a user