-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(website): Workflow fixes (#19046)
feat: update how secrets are being passed and used
- Loading branch information
1 parent
f33dce2
commit fb63f8e
Showing
2 changed files
with
20 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,18 +11,19 @@ on: | |
description: "Application name for the comment" | ||
required: true | ||
type: string | ||
secrets: | ||
REQUEST_TOKEN: | ||
description: "Token for the request" | ||
required: true | ||
type: secret | ||
REQUEST_MESSAGE: | ||
description: "Message for the request" | ||
required: true | ||
type: secret | ||
ENDPOINT: | ||
description: "Request endpoint" | ||
required: true | ||
type: secret | ||
GITHUB_TOKEN: | ||
description: "GitHub Token" | ||
required: true | ||
|
||
jobs: | ||
create_preview_site: | ||
|
@@ -59,6 +60,12 @@ jobs: | |
# Kick off the job in amplify | ||
- name: Deploy Site | ||
env: | ||
APP_ID: ${{ inputs.APP_ID }} | ||
APP_NAME: ${{ inputs.APP_NAME }} | ||
REQUEST_TOKEN: ${{ secrets.REQUEST_TOKEN }} | ||
REQUEST_MESSAGE: ${{ secrets.REQUEST_MESSAGE }} | ||
ENDPOINT: ${{ secrets.ENDPOINT }} | ||
run: | | ||
HMAC_KEY=$(echo -n $REQUEST_MESSAGE | openssl dgst -sha256 -hmac "$REQUEST_TOKEN" -binary | od -An -tx1 | tr -d ' \n'; echo) | ||
SIGNATURE="sha256=$HMAC_KEY" | ||
|
@@ -79,16 +86,19 @@ jobs: | |
if: success() | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
APP_ID: ${{ inputs.APP_ID }} | ||
APP_NAME: ${{ inputs.APP_NAME }} | ||
uses: actions/[email protected] | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
const prNumber = fs.readFileSync('./pr/number', 'utf8'); | ||
const issueNumber = parseInt(prNumber); | ||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: issue_number, | ||
issue_number: issueNumber, | ||
body: `Your preview site for the **${APP_NAME}** will be ready in a few minutes, please allow time for it to build. \n \n Heres your preview link: \n [${APP_NAME} preview](https://${SANITIZED_BRANCH_NAME}.${APP_ID}.amplifyapp.com)` | ||
}); | ||
|