Created
November 11, 2021 08:29
-
-
Save etiennetremel/57350277cda740b82e936b6e350a9682 to your computer and use it in GitHub Desktop.
Report all packages size for a given Github organization as CSV
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
#!/usr/bin/env bash | |
# The following script get all packages from a given organization and generate | |
# a CSV file reporting package size | |
# Usage: | |
# bash github-get-graphql-packages-by-size-csv.sh MyGithubOrganization | |
set -e | |
echo "repository,package,version,file,size" | |
gh api graphql -F organization=$1 --paginate -f query=' | |
query($organization: String!, $endCursor: String) { | |
organization(login: $organization) { | |
packages(last: 100, after: $endCursor) { | |
nodes { | |
name, | |
repository { | |
name | |
} | |
versions(last: 1, orderBy: {field: CREATED_AT, direction: ASC}) { | |
nodes { | |
files(last: 1) { | |
nodes { | |
name | |
size | |
} | |
} | |
version | |
} | |
} | |
} | |
pageInfo { | |
hasNextPage | |
endCursor | |
} | |
} | |
} | |
} | |
' --jq '.data.organization.packages.nodes[] | [.repository.name, .name, .versions.nodes[0].version, .versions.nodes[0].files.nodes[0].name, .versions.nodes[0].files.nodes[0].size] | @csv' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment