-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHub app installation access token.
Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/zsh -Ndefgku | ||
# | ||
# script/generate_token | ||
# mas | ||
# | ||
# Generates a GitHub App installation access token for GitHub Workflows. | ||
# | ||
|
||
. "${0:a:h}/_setup_script" | ||
|
||
header=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9 | ||
payload="${${$(printf '{"iss":%s,"iat":%s,"exp":%s}' "${TOKEN_APP_ID}" "$(("$(date +%s)" - 60))"\ | ||
"$(("$(date +%s)" + 540))" | base64)//[=$'\n']}//\/+/_-}" | ||
|
||
|
||
# shellcheck disable=SC1009,SC1036,SC1072,SC1073 | ||
curl\ | ||
-sX POST\ | ||
-H "Authorization: Bearer ${header}.${payload}.${${$(printf %s "${header}.${payload}" | | ||
openssl dgst -sha256 -sign =(printf %s "${TOKEN_APP_PRIVATE_KEY}") | base64)//[=$'\n']}//\/+/_-}"\ | ||
-H 'Accept: application/vnd.github+json'\ | ||
"https://api.github.com/app/installations/${TOKEN_APP_INSTALLATION_ID}/access_tokens" | | ||
jq -r .token |