Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/scripts/check-container-health.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -e

echo "Checking the health of the containers..."

SERVICES="$1"

for service in $SERVICES; do
running=$(docker inspect -f '{{.State.Running}}' "$service" 2>/dev/null || echo "false")

if [ "$running" = "true" ]; then
echo "$service is running ✔️"
else
exit_code=$(docker inspect -f '{{.State.ExitCode}}' "$service" 2>/dev/null || echo "1")
if [ "$exit_code" = "0" ]; then
echo "$service is stopped but exited with code 0 ✔️"
else
echo "::error ::$service is stopped and exited with code $exit_code"
exit 1
fi
fi
done
20 changes: 1 addition & 19 deletions .github/workflows/spring-kafka-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,4 @@ jobs:

- name: Check container health
run: |
echo "Checking the health of the containers..."

SERVICES="${{ steps.services.outputs.services }}"

for service in $SERVICES; do
running=$(docker inspect -f '{{.State.Running}}' "$service" 2>/dev/null || echo "false")

if [ "$running" = "true" ]; then
echo "$service is running ✔️"
else
exit_code=$(docker inspect -f '{{.State.ExitCode}}' "$service" 2>/dev/null || echo "1")
if [ "$exit_code" = "0" ]; then
echo "$service is stopped but exited with code 0 ✔️"
else
echo "::error ::$service is stopped and exited with code $exit_code ❌"
exit 1
fi
fi
done
./.github/scripts/check-container-health.sh "${{ steps.services.outputs.services }}"
12 changes: 1 addition & 11 deletions .github/workflows/spring-prometheus-grafana-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,4 @@ jobs:

- name: Check container health
run: |
echo "Checking the health of the containers..."

SERVICES="${{ steps.services.outputs.services }}"
for service in $SERVICES; do
status=$(docker inspect -f '{{.State.Running}}' "$service" || echo "false")
echo "$service status: $status"
if [ "$status" != "true" ]; then
echo "::error ::Service $service is not running."
exit 1
fi
done
./.github/scripts/check-container-health.sh "${{ steps.services.outputs.services }}"