Skip to content

Commit

Permalink
fix: shellcheck og formatering
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrremann committed Nov 11, 2021
1 parent cf9b83e commit 3166d1f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions get-installation-access-token.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ export PRIVATE_KEY=${1:?Usage: ${0} <private-key> <app-id>}
export APP_ID=${2:?Usage: ${0} <private-key> <app-id>}
repo=${GITHUB_REPOSITORY:?Missing required GITHUB_REPOSITORY environment variable}

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

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)
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)

if [ "$installation_id" = "null" ]; then
echo "Unable to get installation ID. Is the GitHub App installed on ${repo}?"
echo $(echo $response | jq -r .message)
echo "$response" | jq -r .message
exit 1
fi

token=$(curl -s -X POST \
-H "Authorization: Bearer ${jwt}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/app/installations/${installation_id}/access_tokens | jq -r .token)
-H "Authorization: Bearer ${jwt}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/app/installations/"${installation_id}"/access_tokens | jq -r .token)

if [ "$token" = "null" ]; then
echo "Unable to generate installation access token"
exit 1
echo "Unable to generate installation access token"
exit 1
fi

echo ::set-output name=token::${token}
echo "::set-output name=token::${token}"

0 comments on commit 3166d1f

Please sign in to comment.