diff --git a/.github/workflows/awscleanup.yaml b/.github/workflows/awscleanup.yaml index b6b06f51..172902d6 100644 --- a/.github/workflows/awscleanup.yaml +++ b/.github/workflows/awscleanup.yaml @@ -61,14 +61,15 @@ jobs: # 1. make sure .jobs exist in response # e.g. { "message": "Not Found", "documentation_url": "https://docs.github.com/rest", "status": "404" } # 2. check if all jobs completed - is_jobs_not_completed=1 - echo "SHIVA $response" - jobs_exist=$(echo "$response" | jq -e '.jobs? // null' >/dev/null 2>&1; echo $?) - if [[ "$jobs_exist" -ne 0 ]]; then - is_jobs_not_completed=$(echo "$response" | jq -r ".jobs? // [] | + + if ! echo "$response" | jq -e '.jobs != null' >/dev/null 2>&1; then + continue + fi + + is_jobs_not_completed=$(echo "$response" | jq -r ".jobs? // [] | map(select(.status != \"completed\")) | length") - fi + if [[ "$is_jobs_not_completed" -eq 0 ]]; then echo "Holodeck e2e Job status is not in running stage , Delete the vpc $vpc and dependent resources" scripts/awscleanup.sh $vpc