From 4c925cbeb3bd76bd06a4637d961b6d71f77a8329 Mon Sep 17 00:00:00 2001 From: Anahide Tchertchian <608958+atchertchian@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:11:09 +0100 Subject: [PATCH] simplify bash logic --- .github/actions/send-teams-notification/action.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/actions/send-teams-notification/action.yml b/.github/actions/send-teams-notification/action.yml index 19eb36cd3..5a6a64af8 100644 --- a/.github/actions/send-teams-notification/action.yml +++ b/.github/actions/send-teams-notification/action.yml @@ -37,16 +37,15 @@ runs: if: ${{ inputs.status == '' }} shell: bash run: | - url="${GITHUB_API_URL}/repos" - repo="${GITHUB_REPOSITORY}" - run_id="${GITHUB_RUN_ID}" - token="${{ github.token }}" + API_URL="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs?per_page=100" - failure=$(curl -s -H "Authorization: token ${token}" "${url}/${repo}/actions/runs/${run_id}/jobs?per_page=100" | \ + RUNS=$(curl -s -H "Authorization: token ${{ github.token }}" "${API_URL}") + + failure=$(echo $RUNS | \ jq -r '.jobs[].steps[] | select(.status == "completed" and .conclusion == "failure").conclusion' | \ wc -l) - cancelled=$(curl -s -H "Authorization: token ${token}" "${url}/${repo}/actions/runs/${run_id}/jobs?per_page=100" | \ + failure=$(echo $RUNS | \ jq -r '.jobs[].steps[] | select(.status == "completed" and .conclusion == "cancelled").conclusion' | \ wc -l)