Skip to content

Commit 0fb7838

Browse files
authored
Merge pull request #1053 from github/aeisenberg/update-checks
Add workflow to regenerate required checks
2 parents 8f84542 + b71f20d commit 0fb7838

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
# This job updates the required checks on the codeql-action repository based on the
3+
# checks performed on the most recent commit.
4+
5+
name: Update required checks
6+
on:
7+
schedule:
8+
# 23:01 on Saturdays
9+
- cron: "1 23 * * 6"
10+
workflow_dispatch:
11+
12+
jobs:
13+
update-required-checks:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Dump environment
17+
run: env
18+
19+
- name: Dump GitHub context
20+
env:
21+
GITHUB_CONTEXT: '${{ toJson(github) }}'
22+
run: echo "$GITHUB_CONTEXT"
23+
24+
- name: Update checks
25+
run: |
26+
# Update the required checks based on the current branch.
27+
# Typically, this will be main.
28+
echo "Getting checks for $GITHUB_SHA"
29+
30+
# Ignore any checks with "https://", CodeQL, LGTM, and Update checks.
31+
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')"
32+
33+
echo "::group::New Checks"
34+
echo "$CHECKS" | jq
35+
echo "::endgroup::"
36+
37+
echo "{\"contexts\": ${CHECKS}}" > checks.json
38+
echo "Updating main"
39+
gh api -X "PATCH" repos/github/codeql-action/branches/main/protection/required_status_checks --input checks.json
40+
echo "Updating v2"
41+
gh api -X "PATCH" repos/github/codeql-action/branches/releases/v2/protection/required_status_checks --input checks.json
42+
echo "Updating v1"
43+
gh api -X "PATCH" repos/github/codeql-action/branches/releases/v1/protection/required_status_checks --input checks.json

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ Here are a few things you can do that will increase the likelihood of your pull
8080

8181
## Keeping the PR checks up to date (admin access required)
8282

83-
Since the `codeql-action` runs most of its testing through individual Actions workflows, there are over two hundred jobs that need to pass in order for a PR to turn green. Managing these PR checks manually is time consuming and complex. Here is a semi-automated approach.
83+
Since the `codeql-action` runs most of its testing through individual Actions workflows, there are over two hundred jobs that need to pass in order for a PR to turn green. You can regenerate the checks automatically by running the [Update required checks](.github/workflows/update-required-checks.yml) workflow.
8484

85-
To regenerate the PR jobs for the action:
85+
Or you can use this semi-automated approach:
8686

8787
1. In a terminal check out the `SHA` whose checks you want to use as the base. Typically, this will be `main`.
8888
2. From a terminal, run the following commands:

0 commit comments

Comments
 (0)