forked from joshjohanning/github-misc-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-enterprise-owners.sh
More file actions
executable file
·36 lines (29 loc) · 918 Bytes
/
get-enterprise-owners.sh
File metadata and controls
executable file
·36 lines (29 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# gets a list of
# gh cli's token needs to be able to admin enterprise - run this first if it can't
# gh auth refresh -h github.com -s admin:enterprise
# organizationRole
# - OWNER: The user is an administrator (owner) of the enterprise.
# - BILLING_MANAGER: The user is a billing manager of the enterprise.
if [ -z "$1" ]; then
echo "Usage: $0 <enterprise>"
echo "Example: ./get-enterprise-owners.sh avocado-corp"
exit 1
fi
enterprise="$1"
gh api graphql --paginate -f enterpriseSlug=$enterprise -f query='
query ($enterpriseSlug: String!, $endCursor: String) {
enterprise(slug: $enterpriseSlug) {
ownerInfo {
admins(first: 100, role: OWNER, after: $endCursor) {
nodes {
login
}
pageInfo {
endCursor
hasNextPage
}
}
}
}
}' --template '{{range .data.enterprise.ownerInfo.admins.nodes}}{{.login}}{{"\n"}}{{end}}'