Skip to content

Commit a2ba749

Browse files
Merge pull request #11 from tspascoal/get-number-enterprise-projects-count
Add get-organizations-projects-count.sh
2 parents 927ab33 + 97dd296 commit a2ba749

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
@@ -316,6 +316,10 @@ Gets a list of members (via GraphQL) and their role in an organization
316316

317317
Gets the repository count in an organization
318318

319+
## get-organizations-projects-count.sh
320+
321+
Gets the count of projects in all organizations in a given enterprise
322+
319323
## get-organization-team-members.sh
320324

321325
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)