Skip to content

Commit

Permalink
chore(website): Fix commenting step on workflow (vectordotdev#19134)
Browse files Browse the repository at this point in the history
* fix: extra env vars into comment step

* fix: add sleep to allow branch to connect

* fix: update where branch name and sanitized branch name are used
  • Loading branch information
devindford authored and pront committed Nov 15, 2023
1 parent 628f63a commit 342f35a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/create_preview_sites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ jobs:
run: |
unzip pr.zip -d pr
BRANCH_NAME=$(cat ./pr/branch)
SANITIZED_BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/\./-/g')
SANITIZED_BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/[\/\.]/-/g')
echo "SANITIZED_BRANCH_NAME=$SANITIZED_BRANCH_NAME" >> $GITHUB_ENV
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
# Kick off the job in amplify
- name: Deploy Site
Expand All @@ -64,12 +65,13 @@ jobs:
REQUEST_MESSAGE: ${{ secrets.REQUEST_MESSAGE }}
ENDPOINT: ${{ secrets.ENDPOINT }}
run: |
sleep 20
HMAC_KEY=$(echo -n $REQUEST_MESSAGE | openssl dgst -sha256 -hmac "$REQUEST_TOKEN" -binary | od -An -tx1 | tr -d ' \n'; echo)
SIGNATURE="sha256=$HMAC_KEY"
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
-H "Content-Type: application/json" \
-H "X-Hub-Signature: $SIGNATURE" \
-d "{\"app_id\": \"$APP_ID\", \"branch_name\": \"$SANITIZED_BRANCH_NAME\"}" \
-d "{\"app_id\": \"$APP_ID\", \"branch_name\": \"$BRANCH_NAME\"}" \
"$ENDPOINT")
# check the response code and fail if not 200
Expand All @@ -91,6 +93,7 @@ jobs:
const fs = require('fs');
const prNumber = fs.readFileSync('./pr/number', 'utf8');
const issueNumber = parseInt(prNumber);
const { APP_ID, APP_NAME, SANITIZED_BRANCH_NAME } = process.env
await github.rest.issues.createComment({
owner: context.repo.owner,
Expand Down

0 comments on commit 342f35a

Please sign in to comment.