Skip to content

Instantly share code, notes, and snippets.

@jdennes
Last active September 22, 2022 16:31
Show Gist options
  • Save jdennes/11404512 to your computer and use it in GitHub Desktop.
Save jdennes/11404512 to your computer and use it in GitHub Desktop.
Export a list of members from a GitHub organisation

Usage:

Get set up:

$ git clone https://gist.github.com/11404512.git export-members; cd export-members 

Bundle (we're going to use Octokit):

$ bundle install

Replace <org-username> with the username of your organization in export-all-members.rb and/or export-all-members-with-2fa-disabled.rb.

Then export all members:

$ OCTOKIT_ACCESS_TOKEN=<yourtoken> bundle exec ruby export-all-members.rb
$ cat export-all.csv

or, export members with 2FA disabled:

$ OCTOKIT_ACCESS_TOKEN=<yourtoken> bundle exec ruby export-all-members-with-2fa-disabled.rb
$ cat export-2fa-disabled.csv
# Set OCTOKIT_ACCESS_TOKEN to authenticate
require "octokit"
Octokit.auto_paginate = true
members = Octokit.org_members "<org-username>", :filter => "2fa_disabled"
# Then, for example:
require "csv"
CSV.open("export-2fa-disabled.csv", "wb") do |csv|
members.each do |m|
csv << [m[:id], m[:login]] # etc
end
end
# Set OCTOKIT_ACCESS_TOKEN to authenticate
require "octokit"
Octokit.auto_paginate = true
members = Octokit.org_members "<org-username>"
# Then, for example:
require "csv"
CSV.open("export-all.csv", "wb") do |csv|
members.each do |m|
csv << [m[:id], m[:login]] # etc
end
end
source "https://rubygems.org"
gem "octokit"
@ITsupportAmagi
Copy link

Please help me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment