From 17069f3a6da2906520f6af21fa6337c82661f89a Mon Sep 17 00:00:00 2001 From: igorcampos-dev Date: Tue, 29 Jul 2025 18:22:14 -0300 Subject: [PATCH 1/2] chore(ci/cd): adjustment workflow --- .github/scripts/check-container-health.sh | 22 +++++++++++++++++++ .github/workflows/spring-kafka-example.yml | 20 +---------------- .../spring-prometheus-grafana-example.yml | 12 +--------- 3 files changed, 24 insertions(+), 30 deletions(-) create mode 100644 .github/scripts/check-container-health.sh diff --git a/.github/scripts/check-container-health.sh b/.github/scripts/check-container-health.sh new file mode 100644 index 0000000..2ea9e68 --- /dev/null +++ b/.github/scripts/check-container-health.sh @@ -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 diff --git a/.github/workflows/spring-kafka-example.yml b/.github/workflows/spring-kafka-example.yml index fd6fed4..80469a1 100644 --- a/.github/workflows/spring-kafka-example.yml +++ b/.github/workflows/spring-kafka-example.yml @@ -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 }}" diff --git a/.github/workflows/spring-prometheus-grafana-example.yml b/.github/workflows/spring-prometheus-grafana-example.yml index 43228ce..45ddbaa 100644 --- a/.github/workflows/spring-prometheus-grafana-example.yml +++ b/.github/workflows/spring-prometheus-grafana-example.yml @@ -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 \ No newline at end of file + ./.github/scripts/check-container-health.sh "${{ steps.services.outputs.services }}" \ No newline at end of file From dbbc4efbd3e1914d01c8ac09ad8ecc13bc91a92e Mon Sep 17 00:00:00 2001 From: igorcampos-dev Date: Tue, 29 Jul 2025 18:51:58 -0300 Subject: [PATCH 2/2] chore(ci/cd): add permission sh --- .github/scripts/check-container-health.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/scripts/check-container-health.sh diff --git a/.github/scripts/check-container-health.sh b/.github/scripts/check-container-health.sh old mode 100644 new mode 100755