From 98576260be3de67fbf8c3a691dc7618dc8bfbdb3 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Tue, 18 Jun 2024 12:06:47 +0200 Subject: [PATCH 01/23] chore(preview-envs): Add preview env workflows to camunda docs repo --- .github/workflows/preview-env-deploy.yml | 103 +++++++++++++++++++++ .github/workflows/preview-env-teardown.yml | 60 ++++++++++++ docusaurus.config.js | 4 +- 3 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/preview-env-deploy.yml create mode 100644 .github/workflows/preview-env-teardown.yml diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml new file mode 100644 index 00000000000..2bf0a3b7a00 --- /dev/null +++ b/.github/workflows/preview-env-deploy.yml @@ -0,0 +1,103 @@ +name: preview-env-deploy +on: + pull_request: + types: [labeled, synchronize] + +jobs: + deploy-preview: + if: github.event.pull_request.state != 'closed' && (contains( github.event.label.name, 'deploy') || contains( github.event.pull_request.labels.*.name, 'deploy')) + runs-on: ubuntu-22.04 + timeout-minutes: 30 + name: deploy-preview-env + steps: + - uses: actions/checkout@v2 + + - name: Import secrets from Vault + id: secrets + uses: hashicorp/vault-action@d1720f055e0635fd932a1d2a48f87a666a57906c + with: + url: ${{ secrets.VAULT_ADDR }} + method: approle + roleId: ${{ secrets.VAULT_ROLE_ID }} + secretId: ${{ secrets.VAULT_SECRET_ID }} + secrets: | + secret/data/products/camunda-docs/ci/preview-environment PREVIEW_ENV_BUCKET_NAME; + secret/data/products/camunda-docs/ci/preview-environment PREVIEW_ENV_GCLOUD_SA_KEY; + + - name: Install Dependencies + run: npm ci + + - name: Build + env: + NODE_OPTIONS: --max_old_space_size=8192 + DOCS_SITE_URL: https://${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} + DOCS_SITE_BASE_URL: /pr-${{ github.event.number }}/ + run: npm run build + + - name: Authenticate with Google Cloud + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ steps.secrets.outputs.PREVIEW_ENV_GCLOUD_SA_KEY }} + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v2 + + - name: start deployment + uses: bobheadxi/deployments@v1 + id: deployment + with: + step: start + token: "${{ github.token }}" + env: ${{ github.event.repository.name }} + ref: ${{ github.event.pull_request.head.sha }} + + - name: Upload files to google bucket + env: + BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} + run: | + gcloud config set pass_credentials_to_gsutil true + gsutil -m cp -R build/* gs://$BUCKET_NAME/pr-${{ github.event.number }} + + - uses: bobheadxi/deployments@v1 + with: + step: finish + token: "${{ github.token }}" + status: ${{ job.status }} + env: ${{ steps.deployment.outputs.env }} + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + + - name: Find deployment comment + uses: peter-evans/find-comment@v1 + id: find-deployment-comment + env: + BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} + with: + issue-number: ${{ github.event.number }} + body-includes: Preview environment has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. + + - name: Find env tear down comment + uses: peter-evans/find-comment@v1 + id: find-teardown-comment + with: + issue-number: ${{ github.event.number }} + body-includes: Your preview env has been torn down. + + - name: Update env tear down comment + if: steps.find-teardown-comment.outputs.comment-id != '' + uses: peter-evans/create-or-update-comment@v4 + with: + comment-id: ${{ steps.find-teardown-comment.outputs.comment-id }} + body: | + Your preview env has been torn down. + edit-mode: replace + + - name: Create comment + if: steps.find-deployment-comment.outputs.comment-id == '' + uses: peter-evans/create-or-update-comment@v4 + env: + BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} + with: + issue-number: ${{ github.event.number }} + body: | + Preview environment has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. + edit-mode: replace diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml new file mode 100644 index 00000000000..158c34be562 --- /dev/null +++ b/.github/workflows/preview-env-teardown.yml @@ -0,0 +1,60 @@ +name: preview-env-teardown +on: + pull_request: + types: [unlabeled, closed] + +jobs: + tear-dowm-preview-env: + if: github.event.label.name == 'deploy' || (github.event.action == 'closed' && contains( github.event.pull_request.labels.*.name, 'deploy') ) + runs-on: ubuntu-22.04 + timeout-minutes: 20 + name: teardown-preview-env + steps: + - uses: actions/checkout@v2 + + - name: Import secrets + id: secrets + uses: hashicorp/vault-action@d1720f055e0635fd932a1d2a48f87a666a57906c + with: + url: ${{ secrets.VAULT_ADDR }} + method: approle + roleId: ${{ secrets.VAULT_ROLE_ID }} + secretId: ${{ secrets.VAULT_SECRET_ID }} + secrets: | + secret/data/products/camunda-docs/ci/preview-environment PREVIEW_ENV_BUCKET_NAME; + secret/data/products/camunda-docs/ci/preview-environment PREVIEW_ENV_GCLOUD_SA_KEY; + + - name: Authenticate with Google Cloud + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ steps.secrets.outputs.PREVIEW_ENV_GCLOUD_SA_KEY }} + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v2 + + - name: Remove files from Google bucket + env: + BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} + run: | + gcloud config set pass_credentials_to_gsutil true + gsutil -m rm -r gs://$BUCKET_NAME/pr-${{ github.event.number }}/ + + - name: Find Comment + uses: peter-evans/find-comment@v1 + id: find-comment + env: + BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} + with: + issue-number: ${{ github.event.number }} + body-includes: Preview environment has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. + + - name: Update comment + if: steps.find-comment.outputs.comment-id != '' + uses: peter-evans/create-or-update-comment@v4 + env: + BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} + with: + comment-id: ${{ steps.find-comment.outputs.comment-id }} + body: | + Your preview env has been torn down. + edit-mode: replace diff --git a/docusaurus.config.js b/docusaurus.config.js index d5ebc29266d..c8939603360 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -7,9 +7,9 @@ module.exports = { title: "Camunda 8 Docs", tagline: "Documentation for all components of Camunda 8", // url: "https://camunda-cloud.github.io", - url: "https://docs.camunda.io", + url: process.env.DOCS_SITE_URL || "https://docs.camunda.io", // baseUrl: "/camunda-cloud-documentation/", - baseUrl: "/", + baseUrl: process.env.DOCS_SITE_BASE_URL || "/", customFields: { canonicalUrlRoot: "https://docs.camunda.io", }, From 6b6fcee85977ccff1c9acc52c423678b21559f14 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Tue, 18 Jun 2024 18:28:28 +0200 Subject: [PATCH 02/23] test that the comment doesnt get overriden --- docusaurus.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/docusaurus.config.js b/docusaurus.config.js index c8939603360..834fd15d300 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -3,6 +3,7 @@ const { unsupportedVersions } = require("./src/versions"); const latestVersion = require("./src/versions").versionMappings[0].docsVersion; +// test changes module.exports = { title: "Camunda 8 Docs", tagline: "Documentation for all components of Camunda 8", From 615bdd6eb5a904e338fd8d7df60449c86bcbd14f Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Tue, 18 Jun 2024 19:10:33 +0200 Subject: [PATCH 03/23] test that the comment doesnt get overriden --- .github/workflows/preview-env-deploy.yml | 28 ++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index 2bf0a3b7a00..ec78440bfb9 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -24,6 +24,15 @@ jobs: secret/data/products/camunda-docs/ci/preview-environment PREVIEW_ENV_BUCKET_NAME; secret/data/products/camunda-docs/ci/preview-environment PREVIEW_ENV_GCLOUD_SA_KEY; + - name: Find deployment comment + uses: peter-evans/find-comment@v1 + id: find-deployment-comment + env: + BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} + with: + issue-number: ${{ github.event.number }} + body-includes: Preview environment has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. + - name: Install Dependencies run: npm ci @@ -51,6 +60,16 @@ jobs: env: ${{ github.event.repository.name }} ref: ${{ github.event.pull_request.head.sha }} + # If the deployment comment is found, remove the old static files from the bucket + # before uploading the new build + - name: Remove files from Google bucket from previous deployment + if: steps.find-deployment-comment.outputs.comment-id == '' + env: + BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} + run: | + gcloud config set pass_credentials_to_gsutil true + gsutil -m rm -r gs://$BUCKET_NAME/pr-${{ github.event.number }}/ + - name: Upload files to google bucket env: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} @@ -66,15 +85,6 @@ jobs: env: ${{ steps.deployment.outputs.env }} deployment_id: ${{ steps.deployment.outputs.deployment_id }} - - name: Find deployment comment - uses: peter-evans/find-comment@v1 - id: find-deployment-comment - env: - BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} - with: - issue-number: ${{ github.event.number }} - body-includes: Preview environment has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. - - name: Find env tear down comment uses: peter-evans/find-comment@v1 id: find-teardown-comment From e01c55d84c64eee4c7468abb7966f75662a00552 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Tue, 18 Jun 2024 19:33:41 +0200 Subject: [PATCH 04/23] if the deployment exists already then files in the bucket and redeploy --- .github/workflows/preview-env-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index ec78440bfb9..262d5f4a037 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -63,7 +63,7 @@ jobs: # If the deployment comment is found, remove the old static files from the bucket # before uploading the new build - name: Remove files from Google bucket from previous deployment - if: steps.find-deployment-comment.outputs.comment-id == '' + if: steps.find-deployment-comment.outputs.comment-id != '' env: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} run: | From b736ba918f578910e2423dc6dd3ac09f18085425 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Tue, 18 Jun 2024 23:16:08 +0200 Subject: [PATCH 05/23] deploy changes --- docusaurus.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/docusaurus.config.js b/docusaurus.config.js index 834fd15d300..c8939603360 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -3,7 +3,6 @@ const { unsupportedVersions } = require("./src/versions"); const latestVersion = require("./src/versions").versionMappings[0].docsVersion; -// test changes module.exports = { title: "Camunda 8 Docs", tagline: "Documentation for all components of Camunda 8", From 68ab9c42290247677ce11640c3db44bbedb35e9c Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Wed, 19 Jun 2024 00:02:44 +0200 Subject: [PATCH 06/23] deploy changes again --- .github/workflows/preview-env-deploy.yml | 67 +++++++++++----------- .github/workflows/preview-env-teardown.yml | 2 +- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index 262d5f4a037..421bcae4ba3 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -3,6 +3,10 @@ on: pull_request: types: [labeled, synchronize] +concurrency: + cancel-in-progress: true + group: ${{ github.workflow }} + jobs: deploy-preview: if: github.event.pull_request.state != 'closed' && (contains( github.event.label.name, 'deploy') || contains( github.event.pull_request.labels.*.name, 'deploy')) @@ -24,18 +28,18 @@ jobs: secret/data/products/camunda-docs/ci/preview-environment PREVIEW_ENV_BUCKET_NAME; secret/data/products/camunda-docs/ci/preview-environment PREVIEW_ENV_GCLOUD_SA_KEY; - - name: Find deployment comment - uses: peter-evans/find-comment@v1 - id: find-deployment-comment - env: - BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} - with: - issue-number: ${{ github.event.number }} - body-includes: Preview environment has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. - - name: Install Dependencies run: npm ci + - name: start deployment + uses: bobheadxi/deployments@v1 + id: deployment + with: + step: start + token: "${{ github.token }}" + env: ${{ github.event.repository.name }} + ref: ${{ github.event.pull_request.head.sha }} + - name: Build env: NODE_OPTIONS: --max_old_space_size=8192 @@ -51,31 +55,12 @@ jobs: - name: Set up Cloud SDK uses: google-github-actions/setup-gcloud@v2 - - name: start deployment - uses: bobheadxi/deployments@v1 - id: deployment - with: - step: start - token: "${{ github.token }}" - env: ${{ github.event.repository.name }} - ref: ${{ github.event.pull_request.head.sha }} - - # If the deployment comment is found, remove the old static files from the bucket - # before uploading the new build - - name: Remove files from Google bucket from previous deployment - if: steps.find-deployment-comment.outputs.comment-id != '' - env: - BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} - run: | - gcloud config set pass_credentials_to_gsutil true - gsutil -m rm -r gs://$BUCKET_NAME/pr-${{ github.event.number }}/ - - name: Upload files to google bucket env: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} run: | gcloud config set pass_credentials_to_gsutil true - gsutil -m cp -R build/* gs://$BUCKET_NAME/pr-${{ github.event.number }} + gsutil -m rsync -d -r build gs://$BUCKET_NAME/pr-${{ github.event.number }} - uses: bobheadxi/deployments@v1 with: @@ -84,6 +69,11 @@ jobs: status: ${{ job.status }} env: ${{ steps.deployment.outputs.env }} deployment_id: ${{ steps.deployment.outputs.deployment_id }} + env_url: https://${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}/pr-${{ github.event.number }}/index.html + + - name: Short commit SHA + id: extract_sha + run: echo "short_sha=$(echo ${{ github.sha }} | cut -c1-10)" >> $GITHUB_ENV - name: Find env tear down comment uses: peter-evans/find-comment@v1 @@ -95,19 +85,30 @@ jobs: - name: Update env tear down comment if: steps.find-teardown-comment.outputs.comment-id != '' uses: peter-evans/create-or-update-comment@v4 + env: + BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} with: comment-id: ${{ steps.find-teardown-comment.outputs.comment-id }} body: | - Your preview env has been torn down. + The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. edit-mode: replace - - name: Create comment - if: steps.find-deployment-comment.outputs.comment-id == '' + - name: Find deployment comment + uses: peter-evans/find-comment@v1 + id: find-deployment-comment + env: + BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} + with: + issue-number: ${{ github.event.number }} + body-includes: Preview environment has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. + + - name: Upsert deployment comment + if: steps.find-deployment-comment.outputs.comment-id == '' && steps.find-teardown-comment.outputs.comment-id == '' uses: peter-evans/create-or-update-comment@v4 env: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} with: issue-number: ${{ github.event.number }} body: | - Preview environment has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. + The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. edit-mode: replace diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml index 158c34be562..5e09a557f4f 100644 --- a/.github/workflows/preview-env-teardown.yml +++ b/.github/workflows/preview-env-teardown.yml @@ -46,7 +46,7 @@ jobs: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} with: issue-number: ${{ github.event.number }} - body-includes: Preview environment has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. + body-includes: The preview environment relating to the commit - name: Update comment if: steps.find-comment.outputs.comment-id != '' From 6a4e9f20cbe2f526f4fde1db71a5ac8a23c34a01 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Thu, 20 Jun 2024 12:26:01 +0200 Subject: [PATCH 07/23] test concurency --- .github/workflows/preview-env-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index 421bcae4ba3..0f12c1fca19 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -5,7 +5,7 @@ on: concurrency: cancel-in-progress: true - group: ${{ github.workflow }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} jobs: deploy-preview: From da23ab5eaef9b1f70fe9bef9f7a31ee4158e89dc Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Thu, 20 Jun 2024 12:47:39 +0200 Subject: [PATCH 08/23] modify comment update logic --- .github/workflows/preview-env-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index 0f12c1fca19..97ffb8f5fa5 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -100,9 +100,9 @@ jobs: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} with: issue-number: ${{ github.event.number }} - body-includes: Preview environment has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. + body-includes: The preview environment relating to the commit - - name: Upsert deployment comment + - name: Add deployment comment if: steps.find-deployment-comment.outputs.comment-id == '' && steps.find-teardown-comment.outputs.comment-id == '' uses: peter-evans/create-or-update-comment@v4 env: From d3707ca91bcfa20bf19eef6076937f7355dfeca6 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Thu, 20 Jun 2024 14:02:30 +0200 Subject: [PATCH 09/23] modify comment update logic --- .github/workflows/preview-env-deploy.yml | 30 +++++++++++----------- .github/workflows/preview-env-teardown.yml | 8 +++--- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index 97ffb8f5fa5..5d2335c70b9 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -14,7 +14,7 @@ jobs: timeout-minutes: 30 name: deploy-preview-env steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Import secrets from Vault id: secrets @@ -31,7 +31,14 @@ jobs: - name: Install Dependencies run: npm ci - - name: start deployment + - name: Build Docs + env: + NODE_OPTIONS: --max_old_space_size=8192 + DOCS_SITE_URL: https://${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} + DOCS_SITE_BASE_URL: /pr-${{ github.event.number }}/ + run: npm run build + + - name: Start Deployment uses: bobheadxi/deployments@v1 id: deployment with: @@ -40,13 +47,6 @@ jobs: env: ${{ github.event.repository.name }} ref: ${{ github.event.pull_request.head.sha }} - - name: Build - env: - NODE_OPTIONS: --max_old_space_size=8192 - DOCS_SITE_URL: https://${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} - DOCS_SITE_BASE_URL: /pr-${{ github.event.number }}/ - run: npm run build - - name: Authenticate with Google Cloud uses: google-github-actions/auth@v2 with: @@ -55,7 +55,7 @@ jobs: - name: Set up Cloud SDK uses: google-github-actions/setup-gcloud@v2 - - name: Upload files to google bucket + - name: Upload files to Google bucket env: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} run: | @@ -71,18 +71,18 @@ jobs: deployment_id: ${{ steps.deployment.outputs.deployment_id }} env_url: https://${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}/pr-${{ github.event.number }}/index.html - - name: Short commit SHA + - name: Shorten commit SHA id: extract_sha run: echo "short_sha=$(echo ${{ github.sha }} | cut -c1-10)" >> $GITHUB_ENV - - name: Find env tear down comment - uses: peter-evans/find-comment@v1 + - name: Find tear-down comment + uses: peter-evans/find-comment@v3 id: find-teardown-comment with: issue-number: ${{ github.event.number }} body-includes: Your preview env has been torn down. - - name: Update env tear down comment + - name: Update tear-down comment if: steps.find-teardown-comment.outputs.comment-id != '' uses: peter-evans/create-or-update-comment@v4 env: @@ -94,7 +94,7 @@ jobs: edit-mode: replace - name: Find deployment comment - uses: peter-evans/find-comment@v1 + uses: peter-evans/find-comment@v3 id: find-deployment-comment env: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml index 5e09a557f4f..94662d25272 100644 --- a/.github/workflows/preview-env-teardown.yml +++ b/.github/workflows/preview-env-teardown.yml @@ -10,7 +10,7 @@ jobs: timeout-minutes: 20 name: teardown-preview-env steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Import secrets id: secrets @@ -39,8 +39,8 @@ jobs: gcloud config set pass_credentials_to_gsutil true gsutil -m rm -r gs://$BUCKET_NAME/pr-${{ github.event.number }}/ - - name: Find Comment - uses: peter-evans/find-comment@v1 + - name: Find Deployment Comment + uses: peter-evans/find-comment@v3 id: find-comment env: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} @@ -48,7 +48,7 @@ jobs: issue-number: ${{ github.event.number }} body-includes: The preview environment relating to the commit - - name: Update comment + - name: Update deployment comment if: steps.find-comment.outputs.comment-id != '' uses: peter-evans/create-or-update-comment@v4 env: From ed60532ce052347af23c30bb2ee4c0ed184619b8 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Thu, 20 Jun 2024 14:42:19 +0200 Subject: [PATCH 10/23] ready for review --- .github/workflows/preview-env-teardown.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml index 94662d25272..df7cc3de1e6 100644 --- a/.github/workflows/preview-env-teardown.yml +++ b/.github/workflows/preview-env-teardown.yml @@ -39,7 +39,7 @@ jobs: gcloud config set pass_credentials_to_gsutil true gsutil -m rm -r gs://$BUCKET_NAME/pr-${{ github.event.number }}/ - - name: Find Deployment Comment + - name: Find deployment comment uses: peter-evans/find-comment@v3 id: find-comment env: From 555f0bd7467923e3b01abcd1e2055d50c47ce9d8 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Thu, 20 Jun 2024 14:50:04 +0200 Subject: [PATCH 11/23] ready for review --- .github/workflows/preview-env-deploy.yml | 2 -- .github/workflows/preview-env-teardown.yml | 4 ---- 2 files changed, 6 deletions(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index 5d2335c70b9..8f97d8671fb 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -96,8 +96,6 @@ jobs: - name: Find deployment comment uses: peter-evans/find-comment@v3 id: find-deployment-comment - env: - BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} with: issue-number: ${{ github.event.number }} body-includes: The preview environment relating to the commit diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml index df7cc3de1e6..5f3765b297e 100644 --- a/.github/workflows/preview-env-teardown.yml +++ b/.github/workflows/preview-env-teardown.yml @@ -42,8 +42,6 @@ jobs: - name: Find deployment comment uses: peter-evans/find-comment@v3 id: find-comment - env: - BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} with: issue-number: ${{ github.event.number }} body-includes: The preview environment relating to the commit @@ -51,8 +49,6 @@ jobs: - name: Update deployment comment if: steps.find-comment.outputs.comment-id != '' uses: peter-evans/create-or-update-comment@v4 - env: - BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} with: comment-id: ${{ steps.find-comment.outputs.comment-id }} body: | From 25adc8a298200d86d17fd4a628fef27cce12fc49 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Thu, 20 Jun 2024 14:52:53 +0200 Subject: [PATCH 12/23] ready for review --- .github/workflows/preview-env-teardown.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml index 5f3765b297e..4080cc11032 100644 --- a/.github/workflows/preview-env-teardown.yml +++ b/.github/workflows/preview-env-teardown.yml @@ -5,7 +5,7 @@ on: jobs: tear-dowm-preview-env: - if: github.event.label.name == 'deploy' || (github.event.action == 'closed' && contains( github.event.pull_request.labels.*.name, 'deploy') ) + if: github.event.label.name == 'deploy' || (github.event.action == 'closed' && contains( github.event.pull_request.labels.*.name, 'deploy')) runs-on: ubuntu-22.04 timeout-minutes: 20 name: teardown-preview-env From 9722ae3f6806ce09a37f1c1f26921233994210b8 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Thu, 20 Jun 2024 14:56:15 +0200 Subject: [PATCH 13/23] ready for review --- .github/workflows/preview-env-deploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index 8f97d8671fb..c8d1e8c152f 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -72,7 +72,6 @@ jobs: env_url: https://${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}/pr-${{ github.event.number }}/index.html - name: Shorten commit SHA - id: extract_sha run: echo "short_sha=$(echo ${{ github.sha }} | cut -c1-10)" >> $GITHUB_ENV - name: Find tear-down comment From 0668584592ce1605f191a5141e38d15eb3dc7c2a Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Fri, 21 Jun 2024 11:02:04 +0200 Subject: [PATCH 14/23] revome quotes from token --- .github/workflows/preview-env-deploy.yml | 8 ++++---- .github/workflows/preview-env-teardown.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index c8d1e8c152f..26a6a5c01f1 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -5,7 +5,7 @@ on: concurrency: cancel-in-progress: true - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} jobs: deploy-preview: @@ -43,7 +43,7 @@ jobs: id: deployment with: step: start - token: "${{ github.token }}" + token: ${{ github.token }} env: ${{ github.event.repository.name }} ref: ${{ github.event.pull_request.head.sha }} @@ -65,14 +65,14 @@ jobs: - uses: bobheadxi/deployments@v1 with: step: finish - token: "${{ github.token }}" + token: ${{ github.token }} status: ${{ job.status }} env: ${{ steps.deployment.outputs.env }} deployment_id: ${{ steps.deployment.outputs.deployment_id }} env_url: https://${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}/pr-${{ github.event.number }}/index.html - name: Shorten commit SHA - run: echo "short_sha=$(echo ${{ github.sha }} | cut -c1-10)" >> $GITHUB_ENV + run: echo "short_sha=$(echo ${{ github.sha }} | cut -c1-8)" >> $GITHUB_ENV - name: Find tear-down comment uses: peter-evans/find-comment@v3 diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml index 4080cc11032..1e0ea7c604e 100644 --- a/.github/workflows/preview-env-teardown.yml +++ b/.github/workflows/preview-env-teardown.yml @@ -4,7 +4,7 @@ on: types: [unlabeled, closed] jobs: - tear-dowm-preview-env: + tear-down-preview-env: if: github.event.label.name == 'deploy' || (github.event.action == 'closed' && contains( github.event.pull_request.labels.*.name, 'deploy')) runs-on: ubuntu-22.04 timeout-minutes: 20 From f34e8f25d457f551e87ebd09ef526ca2913c4201 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Fri, 21 Jun 2024 11:30:28 +0200 Subject: [PATCH 15/23] revome quotes from token --- .github/workflows/preview-env-deploy.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index 26a6a5c01f1..628ed0fff72 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -38,15 +38,6 @@ jobs: DOCS_SITE_BASE_URL: /pr-${{ github.event.number }}/ run: npm run build - - name: Start Deployment - uses: bobheadxi/deployments@v1 - id: deployment - with: - step: start - token: ${{ github.token }} - env: ${{ github.event.repository.name }} - ref: ${{ github.event.pull_request.head.sha }} - - name: Authenticate with Google Cloud uses: google-github-actions/auth@v2 with: @@ -59,9 +50,17 @@ jobs: env: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} run: | - gcloud config set pass_credentials_to_gsutil true gsutil -m rsync -d -r build gs://$BUCKET_NAME/pr-${{ github.event.number }} + - name: Start Deployment + uses: bobheadxi/deployments@v1 + id: deployment + with: + step: start + token: ${{ github.token }} + env: ${{ github.event.repository.name }} + ref: ${{ github.event.pull_request.head.sha }} + - uses: bobheadxi/deployments@v1 with: step: finish From 294915ebd77638b81397d22f8e19ed3038728c25 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Mon, 24 Jun 2024 08:56:40 +0200 Subject: [PATCH 16/23] restructured comments --- .github/workflows/preview-env-deploy.yml | 23 ++++++++-------------- .github/workflows/preview-env-teardown.yml | 4 ++-- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index 628ed0fff72..d7ad00b9b81 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -46,12 +46,6 @@ jobs: - name: Set up Cloud SDK uses: google-github-actions/setup-gcloud@v2 - - name: Upload files to Google bucket - env: - BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} - run: | - gsutil -m rsync -d -r build gs://$BUCKET_NAME/pr-${{ github.event.number }} - - name: Start Deployment uses: bobheadxi/deployments@v1 id: deployment @@ -61,6 +55,12 @@ jobs: env: ${{ github.event.repository.name }} ref: ${{ github.event.pull_request.head.sha }} + - name: Upload files to Google bucket + env: + BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} + run: | + gsutil -m rsync -d -r build gs://$BUCKET_NAME/pr-${{ github.event.number }} + - uses: bobheadxi/deployments@v1 with: step: finish @@ -78,7 +78,7 @@ jobs: id: find-teardown-comment with: issue-number: ${{ github.event.number }} - body-includes: Your preview env has been torn down. + body-includes: - name: Update tear-down comment if: steps.find-teardown-comment.outputs.comment-id != '' @@ -91,15 +91,8 @@ jobs: The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. edit-mode: replace - - name: Find deployment comment - uses: peter-evans/find-comment@v3 - id: find-deployment-comment - with: - issue-number: ${{ github.event.number }} - body-includes: The preview environment relating to the commit - - name: Add deployment comment - if: steps.find-deployment-comment.outputs.comment-id == '' && steps.find-teardown-comment.outputs.comment-id == '' + if: steps.find-teardown-comment.outputs.comment-id == '' uses: peter-evans/create-or-update-comment@v4 env: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml index 1e0ea7c604e..5bd5a7d45e7 100644 --- a/.github/workflows/preview-env-teardown.yml +++ b/.github/workflows/preview-env-teardown.yml @@ -44,7 +44,7 @@ jobs: id: find-comment with: issue-number: ${{ github.event.number }} - body-includes: The preview environment relating to the commit + body-includes: - name: Update deployment comment if: steps.find-comment.outputs.comment-id != '' @@ -52,5 +52,5 @@ jobs: with: comment-id: ${{ steps.find-comment.outputs.comment-id }} body: | - Your preview env has been torn down. + Your preview env has been torn down. edit-mode: replace From 60ea3c4e852bf1bca59cce320f7d3c7256a9b9d9 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Mon, 24 Jun 2024 09:44:57 +0200 Subject: [PATCH 17/23] restructured comments --- .github/workflows/preview-env-teardown.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml index 5bd5a7d45e7..26cd748c1da 100644 --- a/.github/workflows/preview-env-teardown.yml +++ b/.github/workflows/preview-env-teardown.yml @@ -39,6 +39,15 @@ jobs: gcloud config set pass_credentials_to_gsutil true gsutil -m rm -r gs://$BUCKET_NAME/pr-${{ github.event.number }}/ + - uses: bobheadxi/deployments@v1 + if: always() + name: Deactivate GitHub Deployment environment + with: + step: delete-env + token: ${{ github.token }} + env: ${{ github.event.repository.name }} + ref: ${{ github.event.pull_request.head.sha }} + - name: Find deployment comment uses: peter-evans/find-comment@v3 id: find-comment From 08a3998d57a575228e288b12f6bc81e320595420 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Mon, 24 Jun 2024 09:59:04 +0200 Subject: [PATCH 18/23] restructured comments --- .github/workflows/preview-env-teardown.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml index 26cd748c1da..0e2512e0a0a 100644 --- a/.github/workflows/preview-env-teardown.yml +++ b/.github/workflows/preview-env-teardown.yml @@ -36,7 +36,6 @@ jobs: env: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} run: | - gcloud config set pass_credentials_to_gsutil true gsutil -m rm -r gs://$BUCKET_NAME/pr-${{ github.event.number }}/ - uses: bobheadxi/deployments@v1 From d2721e0ed36f78dd8a2a9423feb315a83712d555 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Mon, 24 Jun 2024 09:59:46 +0200 Subject: [PATCH 19/23] restructured comments --- .github/workflows/preview-env-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index d7ad00b9b81..a75775c92dc 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -88,7 +88,7 @@ jobs: with: comment-id: ${{ steps.find-teardown-comment.outputs.comment-id }} body: | - The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. + The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. edit-mode: replace - name: Add deployment comment @@ -99,5 +99,5 @@ jobs: with: issue-number: ${{ github.event.number }} body: | - The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. + The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. edit-mode: replace From 55948d36e08e436379b991bffd1b103a470414b7 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Mon, 24 Jun 2024 10:32:40 +0200 Subject: [PATCH 20/23] restructured comments --- .github/workflows/preview-env-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index a75775c92dc..2a39c7added 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -88,7 +88,7 @@ jobs: with: comment-id: ${{ steps.find-teardown-comment.outputs.comment-id }} body: | - The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. + The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html . edit-mode: replace - name: Add deployment comment @@ -99,5 +99,5 @@ jobs: with: issue-number: ${{ github.event.number }} body: | - The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. + The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html . edit-mode: replace From 005bf61314583dd97edd4698f97d52c3b81e90cc Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Mon, 24 Jun 2024 10:56:11 +0200 Subject: [PATCH 21/23] removed a tag --- .github/workflows/preview-env-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index 2a39c7added..a75775c92dc 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -88,7 +88,7 @@ jobs: with: comment-id: ${{ steps.find-teardown-comment.outputs.comment-id }} body: | - The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html . + The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. edit-mode: replace - name: Add deployment comment @@ -99,5 +99,5 @@ jobs: with: issue-number: ${{ github.event.number }} body: | - The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html . + The preview environment relating to the commit ${{ env.short_sha }} has successfully been deployed. You can access it on https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html. edit-mode: replace From 9feec67b486d08c277c35d65928eb726bdd59fa2 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Mon, 24 Jun 2024 12:16:22 +0200 Subject: [PATCH 22/23] deactivate preview env --- .github/workflows/preview-env-teardown.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml index 0e2512e0a0a..f369c95b302 100644 --- a/.github/workflows/preview-env-teardown.yml +++ b/.github/workflows/preview-env-teardown.yml @@ -42,7 +42,7 @@ jobs: if: always() name: Deactivate GitHub Deployment environment with: - step: delete-env + step: deactivate-env token: ${{ github.token }} env: ${{ github.event.repository.name }} ref: ${{ github.event.pull_request.head.sha }} From 18c70b6fb7b67c0a1edb5ce5bb3494a0367942a9 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Mon, 24 Jun 2024 14:13:26 +0200 Subject: [PATCH 23/23] deactivate preview env --- .github/workflows/preview-env-deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index a75775c92dc..0cba5a4936e 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -16,6 +16,7 @@ jobs: steps: - uses: actions/checkout@v4 + # dummy comment - name: Import secrets from Vault id: secrets uses: hashicorp/vault-action@d1720f055e0635fd932a1d2a48f87a666a57906c