diff --git a/.github/actions/deploy-environment/action.yml b/.github/actions/deploy-environment/action.yml index 0a62d165..282201d4 100644 --- a/.github/actions/deploy-environment/action.yml +++ b/.github/actions/deploy-environment/action.yml @@ -47,15 +47,47 @@ runs: run: | access_url=$(terraform -chdir=terraform/application output -json urls | jq -r '.[0]') echo "ACCESS_URL=$access_url" >> $GITHUB_OUTPUT + check_url=$(terraform -chdir=terraform/application output -json urls | jq -r '.[1]') + echo "CHECK_URL=$check_url" >> $GITHUB_OUTPUT + + access_external_domain=$(terraform -chdir=terraform/application output -raw local.access_external_domain 2>/dev/null || echo "") + check_external_domain=$(terraform -chdir=terraform/application output -raw local.check_external_domain 2>/dev/null || echo "") + echo "ACCESS_EXTERNAL_DOMAIN=$access_external_domain" >> $GITHUB_OUTPUT + echo "CHECK_EXTERNAL_DOMAIN=$check_external_domain" >> $GITHUB_OUTPUT - name: Run smoke tests shell: bash run: | - # Parse the JSON array of URLs into a Bash array - urls=$(echo "$HOSTNAMES" | jq -r '.[]') + # Parse the JSON array of internal URLs into a Bash array + internal_urls=$(terraform -chdir=terraform/application output -json urls | jq -r '.[]') + + # Get the external domains + access_external_domain="${{ steps.set_outputs.outputs.ACCESS_EXTERNAL_DOMAIN }}" + check_external_domain="${{ steps.set_outputs.outputs.CHECK_EXTERNAL_DOMAIN }}" + + echo "Internal URLs:" + echo "$internal_urls" - # Loop over each URL and perform the curl check on the /health/all.json endpoint - for url in $urls; do + # Function to perform health check + perform_health_check() { + local url="$1" + echo "Check health for $url..." + curl -sS --fail "$url" > /dev/null && echo "Health check passed for $url" || echo "Health check failed for $url" echo "Check health for $url/health/all.json..." - curl -sS --fail "$url/health/all.json" > /dev/null && echo "Health check passed for $url" || echo "Health check failed for $url" + curl -sS --fail "$url/health/all.json" > /dev/null && echo "Health check passed for $url/health/all.json" || echo "Health check failed for $url/health/all.json" + } + + # Loop over each internal URL and perform the health checks + for url in $internal_urls; do + perform_health_check "$url" done + + # Perform health checks on external domains if they exist + if [ -n "$access_external_domain" ] && [ -n "$check_external_domain" ]; then + echo "Access External Domain: $access_external_domain" + echo "Check External Domain: $check_external_domain" + perform_health_check "https://$access_external_domain" + perform_health_check "https://$check_external_domain" + else + echo "External domains not available. Skipping external health checks." + fi