Skip to content

Commit 65b476d

Browse files
committed
Create update-required-checks script
This also removes the .github/workflows/update-required-checks.yml workflow. This script needs to be run locally by someone who has admin privileges on the repo.
1 parent dd56e95 commit 65b476d

File tree

2 files changed

+33
-45
lines changed

2 files changed

+33
-45
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
# Update the required checks based on the current branch.
3+
# Typically, this will be main.
4+
5+
# NOTE: This script can only be run by someone with admin rights on this repo.
6+
7+
if [ "$#" -eq 1 ]; then
8+
# If we were passed an argument, pass it as a query to fzf
9+
GITHUB_SHA="$@"
10+
elif [ "$#" -gt 1 ]; then
11+
echo "Usage: $0 [SHA]"
12+
echo "Update the required checks based on the SHA, or main."
13+
elif [ -z "$GITHUB_SHA" ]; then
14+
# If we don't have a SHA, use main
15+
GITHUB_SHA="$(git rev-parse main)"
16+
fi
17+
18+
echo "Getting checks for $GITHUB_SHA"
19+
20+
# Ignore any checks with "https://", CodeQL, LGTM, and Update checks.
21+
CHECKS="$(gh api repos/github/codeql-action/commits/${GITHUB_SHA}/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or contains("Update") | not)] | sort')"
22+
23+
echo "$CHECKS" | jq
24+
25+
echo "{\"contexts\": ${CHECKS}}" > checks.json
26+
echo "Updating main"
27+
gh api --silent -X "PATCH" repos/github/codeql-action/branches/main/protection/required_status_checks --input checks.json
28+
echo "Updating v2"
29+
gh api --silent -X "PATCH" repos/github/codeql-action/branches/releases/v2/protection/required_status_checks --input checks.json
30+
echo "Updating v1"
31+
gh api --silent -X "PATCH" repos/github/codeql-action/branches/releases/v1/protection/required_status_checks --input checks.json
32+
33+
rm check.json

.github/workflows/update-required-checks.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)