From 04d521d70560142c41136dc702bf028e2a88b5e3 Mon Sep 17 00:00:00 2001 From: Andrew Eisenberg Date: Wed, 9 Mar 2022 11:07:16 -0800 Subject: [PATCH] Avoid using `sed`, use `--slurp` instead --- CONTRIBUTING.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 013c616e1..d122b8c76 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,7 +72,7 @@ Here are a few things you can do that will increase the likelihood of your pull Approve the mergeback PR and automerge it. Once the mergeback has been merged into main, the release is complete. -## Keeping the PR checks up to date (requires admin access) +## Keeping the PR checks up to date (admin access required) 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. @@ -82,8 +82,7 @@ To regenerate the PR jobs for the action: ```sh SHA= #### - CHECKS="$(gh api repos/github/codeql-action/commits/${SHA}/check-runs --paginate | jq --compact-output --raw-output '[.["check_runs"] | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or . == "Update dependencies" | not)]')" - CHECKS="$(echo $CHECKS | sed -E 's|\].*\[|,|g')" # Because the gh command is paginated, the results are multiple arrays + CHECKS="$(gh api repos/github/codeql-action/commits/${SHA}/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or . == "Update dependencies" | not)]')" echo "{\"contexts\": ${CHECKS}}" > checks.json gh api -X "PATCH" repos/github/codeql-action/branches/main/protection/required_status_checks --input checks.json gh api -X "PATCH" repos/github/codeql-action/branches/v1/protection/required_status_checks --input checks.json