Last active
April 9, 2025 08:58
-
-
Save wuhuizuo/02e15cf574cbeebc122894468e204edf to your computer and use it in GitHub Desktop.
how to list branch protection rules of a repo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query ($owner: String!, $repo: String!) { | |
repository(owner: $owner, name: $repo) { | |
branchProtectionRules(first: 100) { | |
nodes { | |
pattern | |
requiresApprovingReviews | |
requiredApprovingReviewCount | |
requiresStatusChecks | |
requiredStatusCheckContexts | |
requiresStrictStatusChecks | |
requiresCodeOwnerReviews | |
dismissesStaleReviews | |
restrictsReviewDismissals | |
restrictsPushes | |
allowsDeletions | |
allowsForcePushes | |
isAdminEnforced | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. create the query graphql file | |
# 2. run with gh cli: | |
gh api graphql -F [email protected] -F owner=<owner> -F repo=<repo> --jq '.data.repository.branchProtectionRules.nodes' | tee bp.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment