Skip to content

Instantly share code, notes, and snippets.

@kylemacey
Last active August 29, 2015 14:27
Show Gist options
  • Save kylemacey/4e38904dcce6ac74768c to your computer and use it in GitHub Desktop.
Save kylemacey/4e38904dcce6ac74768c to your computer and use it in GitHub Desktop.
Exports all repos for a GHE instance
require 'octokit.rb'
# export GITHUB_TOKEN=000000000000000
# export GITHUB_API_ENDPOINT=http://0.0.0.0/api/v3
# export GHE_HOST=0.0.0.0
# export GHE_PROTOCOL=https
ACCESS_TOKEN = ENV.fetch("GITHUB_TOKEN")
API_ENDPOINT = ENV.fetch("GITHUB_API_ENDPOINT")
HOST = ENV.fetch("GHE_HOST") # github.com
PROTOCOL = ENV.fetch("GHE_PROTOCOL") # https
Octokit.configure do |kit|
kit.api_endpoint = API_ENDPOINT
kit.access_token = ACCESS_TOKEN
kit.auto_paginate = true
kit.connection_options = { ssl: { verify: false } }
end
client = Octokit::Client.new
client.organizations.each do |org|
client.organization_repositories(org[:login]).each do |repo|
puts"#{PROTOCOL}://#{HOST}/#{org[:login]}/#{repo[:name]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment