Created
February 16, 2023 00:04
-
-
Save sjungling/95581e4eea561e75141046f97637aa88 to your computer and use it in GitHub Desktop.
CSV of all organizational repositories and default branch that I have access to that are not archived and have been updated in the last 2 years
This file contains 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
#!/usr/bin/env bash | |
gh api graphql --paginate=true \ | |
-f query='query ( | |
$numOrgs: Int = 100 | |
$numRepos: Int = 100 | |
$endCursor: String | |
) { | |
viewer { | |
organizations(first: $numOrgs) { | |
edges { | |
node { | |
repositories( | |
first: $numRepos | |
after: $endCursor | |
isFork: false | |
isLocked: false | |
) { | |
pageInfo { | |
hasNextPage | |
endCursor | |
} | |
edges { | |
node { | |
nameWithOwner | |
pushedAt | |
defaultBranchRef { | |
name | |
} | |
isArchived | |
isPrivate | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
' \ | |
--jq '.data.viewer.organizations.edges[].node.repositories.edges[].node | select(.isArchived == false and (.pushedAt | fromdateiso8601 | strflocaltime("%Y-%m-%d") > (now - 60 * 60 * 730) ) ) | [.nameWithOwner, .defaultBranchRef.name] | @csv ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This has the limitation of the
gh
CLI auto-pagination, which is only able to do one level of recursion. I chose repositories because I believe those to be far more numerous than organizations an individual might belong to.