Skip to content

Commit

Permalink
Use environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Frederick committed Sep 22, 2014
1 parent 9d58e18 commit 9fcf115
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions api/ruby/enterprise/list_all_ssh_keys.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
require 'octokit'

begin
access_token = ENV.fetch("GITHUB_TOKEN")
hostname = ENV.fetch("GITHUB_HOSTNAME")
rescue KeyError
puts
puts "To run this script, please set the following environment variables:"
puts "- GITHUB_TOKEN: A valid access token"
puts "- GITHUB_HOSTNAME: A valid GitHub Enterprise hostname"
exit 1
end

Octokit.configure do |c|
c.api_endpoint = 'http(s)://HOSTNAME/api/v3'
c.login = 'USERNAME'
c.password = 'PASSWORD'
c.api_endpoint = "#{hostname}/api/v3"
c.access_token = access_token
end

Octokit.auto_paginate = true
Expand Down

0 comments on commit 9fcf115

Please sign in to comment.