diff --git a/.github/workflows/map_new_plugins.yml b/.github/workflows/map_new_plugins.yml index 8260d872d..a4dde835e 100644 --- a/.github/workflows/map_new_plugins.yml +++ b/.github/workflows/map_new_plugins.yml @@ -33,19 +33,26 @@ jobs: completed_checks=0 echo "Using github PR head sha: ${{ github.event.pull_request.head.sha }}" - echo "Option to use github sha: ${{ github.sha }}" # Fetch the status of all checks for this commit statuses=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ "https://api.github.com/repos/brain-score/vision/commits/${{ github.event.pull_request.head.sha }}/status" | jq -r '.statuses[] | {context: .context, state: .state}') + + echo "Statuses response from GitHub API:" + echo "$statuses" | jq '.' - # Check if both required jobs are marked as 'success' + # Parse the statuses and check each required job for success for check in "${required_checks[@]}"; do - if echo "$statuses" | grep -q "$check.*success"; then + if echo "$statuses" | jq -e --arg check "$check" '.statuses[] | select(.context == $check) | select(.state == "success")' > /dev/null; then + echo "Job '$check' is successful." ((completed_checks+=1)) + else + echo "Job '$check' is NOT successful." fi done - + + echo "Completed checks: $completed_checks / ${#required_checks[@]}" + # Fail this step if not all required jobs are completed if [ "$completed_checks" -ne "${#required_checks[@]}" ]; then echo "Not all required Jenkins jobs are complete. Exiting."