Skip to content

Commit

Permalink
Address ShellCheck findings
Browse files Browse the repository at this point in the history
  • Loading branch information
stefaniuk committed Oct 6, 2023
1 parent a4517db commit 7b94f14
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/adr/assets/ADR-003/examples/bash/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function main() {
function get-jwt-token() {

header=$(echo -n '{"alg":"RS256","typ":"JWT"}' | base64 | tr -d '=' | tr -d '\n=' | tr -- '+/' '-_')
payload=$(echo -n '{"iat":'$(date +%s)',"exp":'$(($(date +%s)+600))',"iss":"'$GITHUB_APP_ID'"}' | base64 | tr -d '\n=' | tr -- '+/' '-_')
payload=$(echo -n '{"iat":'"$(date +%s)"',"exp":'$(($(date +%s)+600))',"iss":"'"$GITHUB_APP_ID"'"}' | base64 | tr -d '\n=' | tr -- '+/' '-_')
signature=$(echo -n "$header.$payload" | openssl dgst -binary -sha256 -sign "$GITHUB_APP_PK_FILE" | openssl base64 | tr -d '\n=' | tr -- '+/' '-_')

echo "$header.$payload.$signature"
Expand All @@ -30,17 +30,17 @@ function get-installation-id() {
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/app/installations)

echo "$(echo $installations_response | jq '.[] | select(.account.login == "'"$GITHUB_ORG"'") .id')"
echo "$installations_response" | jq '.[] | select(.account.login == "'"$GITHUB_ORG"'") .id'
}

function get-access-token() {

token_response=$(curl -sX POST \
-H "Authorization: Bearer $jwt_token" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/app/installations/$installation_id/access_tokens)
"https://api.github.com/app/installations/$installation_id/access_tokens")

echo "$(echo $token_response | jq .token -r)"
echo "$token_response" | jq .token -r
}

main

0 comments on commit 7b94f14

Please sign in to comment.