Skip to content

Commit b8806ec

Browse files
authored
Merge pull request #3131 from github/henrymercer/required-checks-safety
CI: Improve safety of update required checks script
2 parents 2b07444 + 33da5f0 commit b8806ec

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

.github/workflows/script/update-required-checks.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env bash
22
# Update the required checks based on the current branch.
33

4+
set -euo pipefail
5+
46
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
57
REPO_DIR="$(dirname "$SCRIPT_DIR")"
68
GRANDPARENT_DIR="$(dirname "$REPO_DIR")"
@@ -31,6 +33,12 @@ CHECKS="$(gh api repos/github/codeql-action/commits/"${GITHUB_SHA}"/check-runs -
3133

3234
echo "$CHECKS" | jq
3335

36+
# Fail if there are no checks
37+
if [ -z "$CHECKS" ] || [ "$(echo "$CHECKS" | jq '. | length')" -eq 0 ]; then
38+
echo "No checks found for $GITHUB_SHA"
39+
exit 1
40+
fi
41+
3442
echo "{\"contexts\": ${CHECKS}}" > checks.json
3543

3644
echo "Updating main"

0 commit comments

Comments
 (0)