Skip to content

Commit 97dd296

Browse files
committed
Add get-organizations-projects-count.sh
Counts the number of projects in all organization in a given enterprise
1 parent 0ac9abc commit 97dd296

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

gh-cli/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ Gets a list of members (via GraphQL) and their role in an organization
281281

282282
Gets the repository count in an organization
283283

284+
## get-organizations-projects-count.sh
285+
286+
Gets the count of projects in all organizations in a given enterprise
287+
284288
## get-organization-team-members.sh
285289

286290
Gets the members of a team
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
if [ $# -ne 1 ]; then
4+
echo "usage: $0 <enterprise slug>"
5+
exit 1
6+
fi
7+
8+
enterprise=$1
9+
10+
gh api graphql -f enterprise="$enterprise" --paginate -f query='query($enterprise:String!, $endCursor: String) {
11+
enterprise(slug:$enterprise) {
12+
organizations(first:100, after: $endCursor) {
13+
pageInfo { hasNextPage endCursor }
14+
nodes {
15+
name
16+
projectsV2(first:1) { totalCount }
17+
}
18+
}
19+
}
20+
}' --jq '.data.enterprise.organizations.nodes[] | [.name, .projectsV2.totalCount] | @tsv'

0 commit comments

Comments
 (0)