Created
November 16, 2021 15:00
-
-
Save jmassardo/93f0bc43341ad2871a248aa2cb3b65f9 to your computer and use it in GitHub Desktop.
A simple ruby script to get a list of orgs and the user count for each.
This file contains 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 ruby | |
require 'octokit' | |
require 'json' | |
client = Octokit::Client.new(access_token: ENV['GITHUB_TOKEN']) | |
query = <<-GRAPHQL | |
query { | |
enterprise(slug: "<MY-ENT-NAME>"){ | |
organizations(first: 100){ | |
nodes{ | |
name | |
} | |
} | |
} | |
} | |
GRAPHQL | |
enterprises = client.post '/graphql', { query: query }.to_json | |
puts enterprises.data.enterprise.organizations.nodes.inspect | |
enterprises.data.enterprise.organizations.nodes.each do |org| | |
puts org.name | |
org_data = client.org_members(org.name) | |
puts org_data.count | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
Replace your enterprise slug on line 10.