Skip to content

Instantly share code, notes, and snippets.

@amenocal
Created October 20, 2022 18:55
Show Gist options
  • Select an option

  • Save amenocal/9295daa8d7159f34c778f1d02c0e372e to your computer and use it in GitHub Desktop.

Select an option

Save amenocal/9295daa8d7159f34c778f1d02c0e372e to your computer and use it in GitHub Desktop.
Repos with Branch Protections in an Org
gh api --paginate graphql -f organization=<orgname> -f query='query($organization: String!, $endCursor: String) {
organization(login: $organization) {
login
repositories(first: 100, after: $endCursor) {
nodes {
nameWithOwner
branchProtectionRules(first: 100, after: $endCursor) {
totalCount
nodes {
repository {
nameWithOwner
}
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}' --jq '.data.organization.repositories.nodes[] | "\(.nameWithOwner),\(.branchProtectionRules.totalCount)"' > org-branch-protections.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment