Skip to content

Instantly share code, notes, and snippets.

@Brantone
Forked from jdennes/Gemfile
Created May 16, 2018 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Brantone/c33091058552df42d281ccbfe9d4e23c to your computer and use it in GitHub Desktop.
Save Brantone/c33091058552df42d281ccbfe9d4e23c 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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment