Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create update-required-checks script #1060

Merged
merged 1 commit into from May 10, 2022

Conversation

aeisenberg
Copy link
Contributor

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.

@aeisenberg aeisenberg requested a review from a team as a code owner May 9, 2022 21:47
echo "Updating v1"
gh api --silent -X "PATCH" repos/github/codeql-action/branches/releases/v1/protection/required_status_checks --input checks.json

rm check.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rm check.json
rm checks.json

Comment on lines 26 to 31
echo "Updating main"
gh api --silent -X "PATCH" repos/github/codeql-action/branches/main/protection/required_status_checks --input checks.json
echo "Updating v2"
gh api --silent -X "PATCH" repos/github/codeql-action/branches/releases/v2/protection/required_status_checks --input checks.json
echo "Updating v1"
gh api --silent -X "PATCH" repos/github/codeql-action/branches/releases/v1/protection/required_status_checks --input checks.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could do this in a loop:

for BRANCH in main releases/v2 releases/v1; do
  ...
done

# Update the required checks based on the current branch.
# Typically, this will be main.

# NOTE: This script can only be run by someone with admin rights on this repo.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a quick failsafe in the script, you can check whether GITHUB_TOKEN is non-empty. Otherwise the first call to gh api will pause and ask for user login.

@aeisenberg aeisenberg force-pushed the aeisenberg/required-checks-script branch from 65b476d to 0fa3d09 Compare May 9, 2022 21:57
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.
@aeisenberg aeisenberg force-pushed the aeisenberg/required-checks-script branch from 0fa3d09 to 827fd55 Compare May 9, 2022 21:59
@aeisenberg aeisenberg enabled auto-merge May 9, 2022 22:40
@aeisenberg aeisenberg merged commit 7cf0ed5 into main May 10, 2022
@aeisenberg aeisenberg deleted the aeisenberg/required-checks-script branch May 10, 2022 09:50
@henrymercer
Copy link
Contributor

@aeisenberg Could we update the CONTRIBUTING.md to refer to this script so we don't duplicate the script for updating the required checks? Thanks!

@github-actions github-actions bot mentioned this pull request May 10, 2022
6 tasks
@aeisenberg
Copy link
Contributor Author

Sure...I'll take care of that in another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants