List all the default branches of repositories in a specific organisation
gh api graphql --paginate \
--jq ' .data.organization.repositories.nodes[] | .defaultBranchRef.name + "\t" + .name' \
-F org=SomeOrg \
-f query='
query($org:String!, $endCursor:String) {
organization(login:$org) {
repositories(first: 100, after: $endCursor, isFork:false, orderBy: {field:NAME, direction:ASC}) {
pageInfo {
hasNextPage
endCursor
}
nodes {
name
defaultBranchRef {
name
}
}
}
}
}
'
List all pull requests for a given repo inside an organisation
gh api graphql \
-F org=SOME_ORG -F repo=SOME_REPO \
-f query='
query allPullRequests($org: String!, $repo: String!, $endCursor: String) {
organization(login: $org) {
repository(name: $repo) {
pullRequests(first: 100, after: $endCursor, states: MERGED,) {
nodes {
author {
login
}
number
createdAt
mergedAt
mergedBy {
login
}
approvers: reviews(states: APPROVED, first: 10) {
nodes {
author {
... on User {
name
login
}
}
state
}
}
title
repository {
owner {
login
}
name
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
}
'