File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # The first argument passed to the script is assigned to the variable ENTERPRISE
4
+ ENTERPRISE=" $1 "
5
+
6
+ # This is a GraphQL query that fetches the first 50 organizations of an enterprise
7
+ # The query takes two variables: slug (the enterprise's slug) and endCursor (for pagination)
8
+ QUERY='
9
+ query($slug:String!, $endCursor:String) {
10
+ enterprise(slug:$slug){
11
+ organizations(first:50, after:$endCursor){
12
+ pageInfo{
13
+ endCursor
14
+ hasNextPage
15
+ }
16
+ nodes {
17
+ login
18
+ }
19
+ }
20
+ }
21
+ }'
22
+
23
+ # This loop iterates over each organization in the enterprise
24
+ # The 'gh api graphql' command is used to execute the GraphQL query
25
+ # The '-f' option is used to pass the query string
26
+ # The '-F' option is used to pass the enterprise's slug
27
+ # The '--jq' option is used to parse the JSON response and extract the login of each organization
28
+ for organization in $( gh api graphql -f query=" ${QUERY} " -F slug=" ${ENTERPRISE} " --jq ' .data.enterprise.organizations.nodes[].login' ) ; do
29
+ # This line prints a message to the console
30
+ echo " Installations for $organization "
31
+ # This line fetches the installations for the current organization
32
+ # The 'gh api' command is used to make a request to the GitHub API
33
+ gh api " /orgs/$organization /installations"
34
+ done
You can’t perform that action at this time.
0 commit comments