From 8bf663f9c712bc0ff02e7983b34aaee4675fd821 Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Thu, 20 Jun 2024 12:51:45 +1000 Subject: [PATCH] refactor: Improve response handling and readability --- .github/actions/checkpoint-sync/action.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/actions/checkpoint-sync/action.yaml b/.github/actions/checkpoint-sync/action.yaml index f0eefdb..cc284d7 100644 --- a/.github/actions/checkpoint-sync/action.yaml +++ b/.github/actions/checkpoint-sync/action.yaml @@ -93,10 +93,11 @@ runs: check_endpoint() { local path=$1 local accept_header=$2 - local response=$(curl -s -H "accept: ${accept_header}" "localhost:5555${path}") - local http_code=$(curl -s -o /dev/null -w "%{http_code}" -H "accept: ${accept_header}" "localhost:5555${path}") + local response=$(curl -s -w "\n%{http_code}" -H "accept: ${accept_header}" "localhost:5555${path}") + local http_code=$(echo "$response" | tail -n1) + local json_response=$(echo "$response" | sed '$d') if [[ $http_code -ge 200 && $http_code -lt 300 ]]; then - echo $response + echo $json_response return 0 else echo "Endpoint ${path} with accept header ${accept_header} is not available."