diff --git a/.github/workflows/script/update-required-checks.sh b/.github/workflows/script/update-required-checks.sh index 950b13c5d4..30a39731b1 100755 --- a/.github/workflows/script/update-required-checks.sh +++ b/.github/workflows/script/update-required-checks.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash # Update the required checks based on the current branch. +set -euo pipefail + SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" REPO_DIR="$(dirname "$SCRIPT_DIR")" GRANDPARENT_DIR="$(dirname "$REPO_DIR")" @@ -31,6 +33,12 @@ CHECKS="$(gh api repos/github/codeql-action/commits/"${GITHUB_SHA}"/check-runs - echo "$CHECKS" | jq +# Fail if there are no checks +if [ -z "$CHECKS" ] || [ "$(echo "$CHECKS" | jq '. | length')" -eq 0 ]; then + echo "No checks found for $GITHUB_SHA" + exit 1 +fi + echo "{\"contexts\": ${CHECKS}}" > checks.json echo "Updating main"