Skip to content

Commit

Permalink
fix: Ruby syntax og formatering
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrremann committed Nov 11, 2021
1 parent 8ce38b8 commit cf9b83e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ WORKDIR /action
RUN gem install jwt && \
apk add jq && \
apk add curl
COPY generate-jwt.rb get-installation-access-token.sh ./
ENTRYPOINT ["/action/get-installation-access-token.sh"]
COPY generate_jwt.rb get-installation-access-token.sh ./
ENTRYPOINT ["/action/get-installation-access-token.sh"]
8 changes: 6 additions & 2 deletions generate-jwt.rb → generate_jwt.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# frozen_string_literal: true

require 'openssl'
require 'jwt'

private_key = ENV.fetch('PRIVATE_KEY')
app_id = ENV.fetch('APP_ID')

puts JWT.encode({
payload = {
iat: Time.now.to_i,
exp: Time.now.to_i + (10 * 60),
iss: app_id
}, OpenSSL::PKey::RSA.new(private_key), 'RS256')
}

puts JWT.encode(payload, OpenSSL::PKey::RSA.new(private_key), 'RS256')
2 changes: 1 addition & 1 deletion get-installation-access-token.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repo=${GITHUB_REPOSITORY:?Missing required GITHUB_REPOSITORY environment variabl

[[ ! -z "$INPUT_REPO" ]] && repo=$INPUT_REPO

jwt=$(ruby $(dirname $0)/generate-jwt.rb)
jwt=$(ruby $(dirname $0)/generate_jwt.rb)
response=$(curl -s -H "Authorization: Bearer ${jwt}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${repo}/installation)
installation_id=$(echo $response | jq -r .id)

Expand Down

0 comments on commit cf9b83e

Please sign in to comment.