query {
rateLimit {
limit
cost
remaining
resetAt
}
organization(login: "YOUR_USERNAME_OR_ORGANIZATION") {
repository(name:"YOUR_REPO") {
owner {
login
}
name
defaultBranchRef {
name
}
branchProtectionRules(first: 100) {
nodes {
pattern
requiresApprovingReviews
dismissesStaleReviews
requiresCodeOwnerReviews
requiredStatusCheckContexts
requiresStatusChecks
restrictsReviewDismissals
requiredApprovingReviewCount
isAdminEnforced
restrictsPushes,
pushAllowances(last:100) {
nodes {
actor {
... on App{
appName: name
id
}
... on User{
userName: name
id
}
... on Team{
teamName: name
id
}
}
}
}
}
}
}
}
}
This is a paged query to get all the branch protection rules for all non forked repos for your organization.
On each call you need to update after: x
where x is the content of pageInfo.endCursor
if hasNextPage == true
query {
rateLimit {
limit
cost
remaining
resetAt
}
organization(login: "YOUR_USERNAME_OR_ORGANIZATION") {
repositories(first: 100,isFork: false after: null) {
pageInfo {
endCursor
hasNextPage
}
nodes {
owner {
login
}
name
defaultBranchRef {
name
}
branchProtectionRules(first: 100) {
nodes {
pattern
requiresApprovingReviews
dismissesStaleReviews
requiresCodeOwnerReviews
requiredStatusCheckContexts
requiresStatusChecks
isAdminEnforced
restrictsPushes
}
}
}
}
}
}