Skip to content

Commit 1a5c2d1

Browse files
updating logic for token
1 parent 802f032 commit 1a5c2d1

File tree

1 file changed

+20
-20
lines changed
  • .github/scripts/ppc64le/self-hosted-builder/helpers

1 file changed

+20
-20
lines changed

.github/scripts/ppc64le/self-hosted-builder/helpers/app_token.sh

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,34 @@ echo "INSTALL_ID: $INSTALL_ID"
2828
echo "APP_PRIVATE_KEY path: $APP_PRIVATE_KEY"
2929

3030
# Generate JWT
31-
# header='{"alg":"RS256","typ":"JWT"}'
32-
# payload="{\"iat\":$(date +%s),\"exp\":$(( $(date +%s) + 600 )),\"iss\":${APP_ID}}"
31+
header='{"alg":"RS256","typ":"JWT"}'
32+
payload="{\"iat\":$(date +%s),\"exp\":$(( $(date +%s) + 600 )),\"iss\":${APP_ID}}"
3333

34-
# header_base64=$(echo -n "$header" | openssl base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n')
35-
# payload_base64=$(echo -n "$payload" | openssl base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n')
34+
header_base64=$(echo -n "$header" | openssl base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n')
35+
payload_base64=$(echo -n "$payload" | openssl base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n')
3636

37-
# signature=$(echo -n "${header_base64}.${payload_base64}" | \
38-
# openssl dgst -sha256 -sign "${APP_PRIVATE_KEY}" | \
39-
# openssl base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n')
37+
signature=$(echo -n "${header_base64}.${payload_base64}" | \
38+
openssl dgst -sha256 -sign "${APP_PRIVATE_KEY}" | \
39+
openssl base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n')
4040

41-
# echo "Contents of APP_PRIVATE_KEY:"
42-
# cat "$APP_PRIVATE_KEY"
41+
echo "Contents of APP_PRIVATE_KEY:"
42+
cat "$APP_PRIVATE_KEY"
4343

4444

45-
# generated_jwt="${header_base64}.${payload_base64}.${signature}"
45+
generated_jwt="${header_base64}.${payload_base64}.${signature}"
4646

47-
# echo $generated_jwt
48-
# API_VERSION=v3
49-
# API_HEADER="Accept: application/vnd.github+json"
47+
echo $generated_jwt
48+
API_VERSION=v3
49+
API_HEADER="Accept: application/vnd.github+json"
5050

51-
# auth_header="Authorization: Bearer ${generated_jwt}"
51+
auth_header="Authorization: Bearer ${generated_jwt}"
5252

53-
# app_installations_response=$(curl -sX POST \
54-
# -H "${auth_header}" \
55-
# -H "${API_HEADER}" \
56-
# --url "https://api.github.com/app/installations/${INSTALL_ID}/access_tokens" \
57-
# )
53+
app_installations_response=$(curl -sX POST \
54+
-H "${auth_header}" \
55+
-H "${API_HEADER}" \
56+
--url "https://api.github.com/app/installations/${INSTALL_ID}/access_tokens" \
57+
)
5858

59-
# echo "$app_installations_response" | jq --raw-output '.token'
59+
echo "$app_installations_response" | jq --raw-output '.token'
6060

6161
#echo "ACCESS_TOKEN=${jwt}" > "${DST_FILE}"

0 commit comments

Comments
 (0)