diff --git a/.github/workflows/build_preview_sites.yml b/.github/workflows/build_preview_sites.yml index 08a1a6dfdbdee..9558c161247d1 100644 --- a/.github/workflows/build_preview_sites.yml +++ b/.github/workflows/build_preview_sites.yml @@ -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 }} diff --git a/.github/workflows/create_preview_sites.yml b/.github/workflows/create_preview_sites.yml index 8c3b500fb5687..78eb9048fc44e 100644 --- a/.github/workflows/create_preview_sites.yml +++ b/.github/workflows/create_preview_sites.yml @@ -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: @@ -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'); @@ -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, @@ -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" @@ -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, diff --git a/.github/workflows/preview_site_trigger.yml b/.github/workflows/preview_site_trigger.yml index b89fe9273973a..bc0c043d84965 100644 --- a/.github/workflows/preview_site_trigger.yml +++ b/.github/workflows/preview_site_trigger.yml @@ -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/ diff --git a/website/amplify.yml b/website/amplify.yml index e1b7f3ac8a13f..d4af1ba79076f 100644 --- a/website/amplify.yml +++ b/website/amplify.yml @@ -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