Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(websites): Setup preview site workflows #18924

Merged
merged 17 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/build_playground_preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Deploy VRL Playground Preview Site

on:
pull_request:
types: [opened, reopened]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given these workflows need access to secrets, I think they need to be on pull_request_target instead of pull_request.


jobs:
deploy_preview_site:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3

# Create the HMAC key
- name: Start Amplify Build
id: hmac_runner
env:
REQUEST_TOKEN: ${{ secrets.REQUEST_TOKEN }}
REQUEST_MESSAGE: ${{ secrets.REQUEST_MESSAGE }}
ENDPOINT: ${{ secrets.BUILDER_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"

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\": \"d2lr4eds605rpz\", \"branch_name\": \"${{ github.head_ref }}\"}" \

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

rpz is not a recognized word. (unrecognized-spelling)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we could pull up the app_id into a workflow environment variable since we refer to it twice.

"$ENDPOINT")

# check the response code and fail if not 200
if [ "$RESPONSE_CODE" != "200" ]; then
echo "Request failed with response code $RESPONSE_CODE"
exit 1
fi

# Add preview link to comment
- name: Comment Preview Link
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
URLIZED_BRANCH=$(echo "${{ github.head_ref }}" | tr './' '--')

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

URLIZED is not a recognized word. (unrecognized-spelling)
COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
COMMENT_CONTENT="Your preview site for the **Vector VRL Playground** will be ready in a few minutes, please allow time for it to build. \n \n Here's your [preview link](https://$URLIZED_BRANCH.d2lr4eds605rpz.amplifyapp.com)."

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

amplifyapp is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

rpz is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

URLIZED is not a recognized word. (unrecognized-spelling)

curl -sSL \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-X POST \
-d "{\"body\": \"$COMMENT_CONTENT\"}" \
$COMMENT_URL
53 changes: 53 additions & 0 deletions .github/workflows/build_rustdoc_preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Deploy Rust Doc Preview Site

on:
pull_request:
types: [opened, reopened]

jobs:
deploy_preview_site:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3

# Create the HMAC key
- name: Start Amplify Build
id: hmac_runner
env:
REQUEST_TOKEN: ${{ secrets.REQUEST_TOKEN }}
REQUEST_MESSAGE: ${{ secrets.REQUEST_MESSAGE }}
ENDPOINT: ${{ secrets.BUILDER_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"

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\": \"d1hoyoksbulg25\", \"branch_name\": \"${{ github.head_ref }}\"}" \

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

hoyoksbulg is not a recognized word. (unrecognized-spelling)
"$ENDPOINT")

# check the response code and fail if not 200
if [ "$RESPONSE_CODE" != "200" ]; then
echo "Request failed with response code $RESPONSE_CODE"
exit 1
fi

# Add preview link to comment
- name: Comment Preview Link
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
URLIZED_BRANCH=$(echo "${{ github.head_ref }}" | tr './' '--')

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

URLIZED is not a recognized word. (unrecognized-spelling)
COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
COMMENT_CONTENT="Your preview site for the **Vector Rust Doc** will be ready in a few minutes, please allow time for it to build. \n \n Here's your [preview link](https://$URLIZED_BRANCH.d1hoyoksbulg25.amplifyapp.com)."

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

hoyoksbulg is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

URLIZED is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

amplifyapp is not a recognized word. (unrecognized-spelling)

curl -sSL \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-X POST \
-d "{\"body\": \"$COMMENT_CONTENT\"}" \
$COMMENT_URL
53 changes: 53 additions & 0 deletions .github/workflows/build_website_preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Deploy Vector Website Preview Site
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big deal, but given these workflows are almost identical, we could create just one parameterized workflow and call it from each of these site-specific workflows. See https://docs.github.com/en/actions/using-workflows/reusing-workflows


on:
pull_request:
types: [opened, reopened]

jobs:
deploy_preview_site:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3

# Create the HMAC key
- name: Start Amplify Build
id: hmac_runner
env:
REQUEST_TOKEN: ${{ secrets.REQUEST_TOKEN }}
REQUEST_MESSAGE: ${{ secrets.REQUEST_MESSAGE }}
ENDPOINT: ${{ secrets.BUILDER_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"

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\": \"d1a7j77663uxsc\", \"branch_name\": \"${{ github.head_ref }}\"}" \

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

uxsc is not a recognized word. (unrecognized-spelling)
"$ENDPOINT")

# check the response code and fail if not 200
if [ "$RESPONSE_CODE" != "200" ]; then
echo "Request failed with response code $RESPONSE_CODE"
exit 1
fi

# Add preview link to comment
- name: Comment Preview Link
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
URLIZED_BRANCH=$(echo "${{ github.head_ref }}" | tr './' '--')

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

URLIZED is not a recognized word. (unrecognized-spelling)
COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
COMMENT_CONTENT="Your preview site for the **Vector Website** will be ready in a few minutes, please allow time for it to build. \n \n Here's your [preview link](https://$URLIZED_BRANCH.d2lr4eds605rpz.amplifyapp.com)."

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

rpz is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

amplifyapp is not a recognized word. (unrecognized-spelling)

curl -sSL \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-X POST \
-d "{\"body\": \"$COMMENT_CONTENT\"}" \
$COMMENT_URL
Loading