Skip to content

Commit

Permalink
Merge pull request #453 from kwiatekus/handle-no-actions-to-check-cas…
Browse files Browse the repository at this point in the history
…e-1.2

Handle no GH actions to check in release flow (#452)
  • Loading branch information
kwiatekus authored Nov 28, 2023
2 parents 5420a58 + ba97ae3 commit d0443b8
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions .github/scripts/verify-actions-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ echo "Checking status of github actions for serverless-manager"

REF_NAME="${1:-"main"}"
RAW_EXPECTED_SHA=$(git log "${REF_NAME}" --max-count 1 --format=format:%H)
STATUS_URL="https://api.github.com/repos/kyma-project/serverless-manager/actions/workflows/gardener-integration.yaml/runs"
JQ_QUERY="[.workflow_runs[] | select(.head_sha | test(\"${RAW_EXPECTED_SHA}\"))][0] | \"\(.status)-\(.conclusion)\""
fullstatus=`curl -s ${STATUS_URL} | jq -r "${JQ_QUERY}"`
REPOSITORY_ID="563346860"

echo $fullstatus
STATUS_URL="https://api.github.com/repositories/${REPOSITORY_ID}/actions/workflows/gardener-integration.yaml/runs?head_sha=${RAW_EXPECTED_SHA}"
GET_STATUS_JQ_QUERY=".workflow_runs[0] | \"\(.status)-\(.conclusion)\""
GET_COUNT_JQ_QUERY=".total_count"

if [[ "$fullstatus" == "completed-success" ]]; then
echo "All actions succeeded"
response=`curl -s ${STATUS_URL}`

count=`echo $response | jq -r "${GET_COUNT_JQ_QUERY}"`
if [[ "$count" == "0" ]]; then
echo "No actions to verify"
else
echo "Actions failed or pending - Check github actions status"
exit 1
fi
fullstatus=`echo $response | jq -r "${GET_STATUS_JQ_QUERY}"`
if [[ "$fullstatus" == "completed-success" ]]; then
echo "All actions succeeded"
else
echo "Actions failed or pending - Check github actions status"
exit 1
fi
fi

0 comments on commit d0443b8

Please sign in to comment.