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): Workflow updates #19036

Merged
merged 3 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions .github/workflows/build_preview_sites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@ jobs:
with:
APP_ID: "d1a7j77663uxsc"
APP_NAME: "vector.dev"
REQUEST_TOKEN: ${{ secrets.REQUEST_TOKEN }}
REQUEST_MESSAGE: ${{ secrets.REQUEST_MESSAGE }}
ENDPOINT: ${{ secrets.BUILDER_ENDPOINT }}

deploy_rust_doc_preview_site:
uses: ./.github/workflows/create_preview_sites.yml
with:
APP_ID: "d1hoyoksbulg25"
APP_NAME: "Rust Doc"
REQUEST_TOKEN: ${{ secrets.REQUEST_TOKEN }}
REQUEST_MESSAGE: ${{ secrets.REQUEST_MESSAGE }}
ENDPOINT: ${{ secrets.BUILDER_ENDPOINT }}

deploy_vrl_playground_preview_site:
uses: ./.github/workflows/create_preview_sites.yml
with:
APP_ID: "d2lr4eds605rpz"
APP_NAME: "VRL Playground"
REQUEST_TOKEN: ${{ secrets.REQUEST_TOKEN }}
REQUEST_MESSAGE: ${{ secrets.REQUEST_MESSAGE }}
ENDPOINT: ${{ secrets.BUILDER_ENDPOINT }}
33 changes: 20 additions & 13 deletions .github/workflows/create_preview_sites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ on:
description: "Application name for the comment"
required: true
type: string
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

jobs:
create_preview_site:
Expand All @@ -19,7 +31,7 @@ jobs:

# Get the artifacts with the PR number and branch name
- name: Download artifact
uses: actions/github-script@v3.1.0
uses: actions/github-script@v6.4.1
with:
script: |
const fs = require('fs');
Expand All @@ -29,7 +41,7 @@ jobs:
run_id: ${{ github.event.workflow_run.id }},
});
const matchArtifact = artifacts.data.artifacts.filter(artifact => artifact.name == "pr")[0];
const download = await github.actions.downloadArtifact({
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
Expand All @@ -41,16 +53,12 @@ jobs:
- name: Extract PR info from artifact
run: |
unzip pr.zip -d pr
BRANCH_NAME=$(cat ./pr/PR_INFO | grep 'Branch Name' | cut -d ':' -f 2 | xargs)
SANITIZED_BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/[\/\.]/-/g')
BRANCH_NAME=$(cat ./pr/branch)
SANITIZED_BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/\./-/g')
echo "SANITIZED_BRANCH_NAME=$SANITIZED_BRANCH_NAME" >> $GITHUB_ENV

# Kick off the job in amplify
- name: Deploy Site
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"
Expand All @@ -71,14 +79,13 @@ jobs:
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/github-script@v3
uses: actions/github-script@v6.4.1
with:
script: |
const prInfo = fs.readFileSync('./pr/PR_INFO', 'utf8');
const prInfoLines = prInfo.split('\n');
const issueNumber = parseInt(prInfoLines[0].split(': ')[1]);
const prNumber = fs.readFileSync('./pr/number', 'utf8');
const issueNumber = parseInt(prNumber);

await github.issues.createComment({
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/preview_site_trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
- name: Save PR number and Branch name
run: |
mkdir -p ./pr
echo "PR Number: ${{ github.event.number }}" > ./pr/PR_INFO
echo "Branch Name: ${{ github.head_ref }}" >> ./pr/PR_INFO
echo "${{ github.event.number }}" > ./pr/number
echo "${{ github.head_ref }}" >> ./pr/branch

# Upload the artifact
- name: Upload PR information artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: pr
path: pr/
3 changes: 2 additions & 1 deletion website/amplify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ applications:
- hugo version
build:
commands:
- if [ ! -n "${AWS_PULL_REQUEST_ID}" ]; then DEPLOY_PRIME_URL="https://$(echo "${AWS_BRANCH}" | sed 's/[./]/-/g').d1a7j77663uxsc.amplifyapp.com"; else DEPLOY_PRIME_URL="https://pr-${AWS_PULL_REQUEST_ID}.d1a7j77663uxsc.amplifyapp.com"; fi
- DEPLOY_PRIME_URL=$(echo "https://$(echo "${AWS_BRANCH}" | sed 's/[./]/-/g').d1a7j77663uxsc.amplifyapp.com" )
- if [[ "${AWS_BRANCH}" =~ ^v0[-.][0-9]+([-.]?[0-9]+)?$ ]]; then DEPLOY_COMMAND="ci-production-build"; fi
- make $DEPLOY_COMMAND
artifacts:
baseDirectory: public
Expand Down
Loading