-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite token in Ruby #17
Conversation
github/token
Outdated
echo $TOKEN | ||
jwt = File.expand_path("jwt", __dir__) | ||
|
||
uri = URI("https://api.github.com/installations/#{ENV["INSTALLATION"]}/access_tokens") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps use ENV.fetch("INSTALLATION")
since this is required?
github/token
Outdated
|
||
uri = URI("https://api.github.com/installations/#{ENV["INSTALLATION"]}/access_tokens") | ||
req = Net::HTTP::Post.new(uri) | ||
req["Authorization"] = "Bearer #{`#{jwt}`}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps execute the jwt
script elsewhere so we can check if it fails? Or write it in Ruby so we can use it as a library here?
|
||
http = Net::HTTP.new(uri.hostname, uri.port) | ||
http.use_ssl = (uri.scheme == "https") | ||
res = http.request(req) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would highly recommend using octokit's built-in method for this if you're going to be using Ruby.
ef4f9e7
to
aaa82ab
Compare
This Ruby version is much less compact than the cURL script, but hopefully it is easier for Ruby devs to understand/debug.
/cc: #3