From 8f6ff4bc415b347cd6c6e3331bda4a0c005055bd Mon Sep 17 00:00:00 2001 From: Vishnu Narayanan Date: Mon, 26 Feb 2024 16:14:01 +0530 Subject: [PATCH] chore: refactor deploy check gh action (#9018) * chore: refactor deploy check action Refactor deployment check gh action to account for the initial setup time required for heroku review apps Process /api response via jq only if http.status_code is 200 --- .github/workflows/deploy_check.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy_check.yml b/.github/workflows/deploy_check.yml index 24664159553a..7fda2b1a446c 100644 --- a/.github/workflows/deploy_check.yml +++ b/.github/workflows/deploy_check.yml @@ -20,15 +20,23 @@ jobs: max_attempts=10 attempt=1 status_code=0 + echo "Waiting for review app to be deployed/redeployed, trying in 10 minutes..." + sleep 600 while [ $attempt -le $max_attempts ]; do - response=$(curl -s https://chatwoot-pr-${{ github.event.pull_request.number }}.herokuapp.com/api) - status_code=$(echo "$response" | jq -r 'if .version and .timestamp and .queue_services and .data_services then 200 else 400 end') - if [ $status_code -eq 200 ]; then - echo "Deployment successful" - exit 0 + response=$(curl -s -o /dev/null -w "%{http_code}" https://chatwoot-pr-${{ github.event.pull_request.number }}.herokuapp.com/api) + status_code=$(echo $response | head -n 1) + if [ $status_code -eq 200 ]; then + body=$(curl -s https://chatwoot-pr-${{ github.event.pull_request.number }}.herokuapp.com/api) + if echo "$body" | jq -e '.version and .timestamp and .queue_services == "ok" and .data_services == "ok"' > /dev/null; then + echo "Deployment successful" + exit 0 + else + echo "Deployment status unknown, retrying in 3 minutes..." + sleep 180 + fi else - echo "Deployment status unknown, retrying in 3 minutes..." - sleep 180 + echo "Waiting for review app to be ready, retrying in 3 minutes..." + sleep 180 attempt=$((attempt + 1)) fi done