From d7537838df43d0ba6683d855028a8b18ce398825 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Wed, 24 Jul 2024 09:29:42 +0200 Subject: [PATCH 1/4] chore(preview-envs): Look into improving commenting of preview environments --- .github/workflows/preview-env-deploy.yml | 50 ++++++++-------------- .github/workflows/preview-env-teardown.yml | 31 ++++++-------- 2 files changed, 30 insertions(+), 51 deletions(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index 42592cadb1..9a857aa871 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -28,21 +28,14 @@ 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 previous deployment or tear-down comment - uses: peter-evans/find-comment@v3 - id: find-comment - with: - issue-number: ${{ github.event.number }} - body-includes: - - name: Upsert comment with build status - uses: peter-evans/create-or-update-comment@v4 + uses: mshick/add-pr-comment@v2 with: - comment-id: ${{ steps.find-comment.outputs.comment-id }} - issue-number: ${{ github.event.number }} - body: | - :construction: The preview environment for the commit ${{ github.sha }} is being built. This usually takes 15-20 minutes. - edit-mode: replace + repo-token: ${{ secrets.GITHUB_TOKEN }} + message-id: preview-env-status + refresh-message-position: true + message: | + :construction: The preview environment for the commit ${{ github.sha }} is being built. This usually takes 15-20 minutes. - name: Install Dependencies run: npm ci @@ -73,21 +66,14 @@ jobs: env: ${{ github.event.repository.name }} ref: ${{ github.event.pull_request.head.sha }} - - name: Find build status comment - uses: peter-evans/find-comment@v3 - id: find-build-comment - with: - issue-number: ${{ github.event.number }} - body-includes: - - name: Update comment with upload status - uses: peter-evans/create-or-update-comment@v4 + uses: mshick/add-pr-comment@v2 with: - comment-id: ${{ steps.find-build-comment.outputs.comment-id }} - issue-number: ${{ github.event.number }} - body: | - :arrow_up: The preview environment build results for commit ${{ github.sha }} is being uploaded. This usually takes 3-4 minutes. - edit-mode: replace + repo-token: ${{ secrets.GITHUB_TOKEN }} + message-id: preview-env-status + refresh-message-position: true + message: | + :arrow_up: The preview environment build results for commit ${{ github.sha }} are being uploaded. This usually takes 3-4 minutes. - name: Upload files to Google bucket env: @@ -105,12 +91,12 @@ jobs: env_url: https://${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}/pr-${{ github.event.number }}/index.html - name: Update comment with deployment status - uses: peter-evans/create-or-update-comment@v4 + uses: mshick/add-pr-comment@v2 env: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} with: - comment-id: ${{ steps.find-build-comment.outputs.comment-id }} - issue-number: ${{ github.event.number }} - body: | - The preview environment relating to the commit ${{ github.sha }} has successfully been deployed. You can access it at [https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html](https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html) - edit-mode: replace + repo-token: ${{ secrets.GITHUB_TOKEN }} + message-id: preview-env-status + refresh-message-position: true + message: | + The preview environment relating to the commit ${{ github.sha }} has successfully been deployed. You can access it at [https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html](https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html). diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml index 900f92815d..168840f39d 100644 --- a/.github/workflows/preview-env-teardown.yml +++ b/.github/workflows/preview-env-teardown.yml @@ -29,21 +29,14 @@ jobs: with: credentials_json: ${{ steps.secrets.outputs.PREVIEW_ENV_GCLOUD_SA_KEY }} - - name: Find deployment status comment - uses: peter-evans/find-comment@v3 - id: find-comment - with: - issue-number: ${{ github.event.number }} - body-includes: - - name: Update comment with tear-down warning - if: steps.find-comment.outputs.comment-id != '' - uses: peter-evans/create-or-update-comment@v4 + uses: mshick/add-pr-comment@v2 with: - comment-id: ${{ steps.find-comment.outputs.comment-id }} - body: | - :warning: Preview environment for commit ${{ github.sha }} is being deleted. This usually takes 2-3 minutes. - edit-mode: replace + repo-token: ${{ secrets.GITHUB_TOKEN }} + message-id: preview-env-status + refresh-message-position: true + message: | + :warning: Preview environment for commit ${{ github.sha }} is being deleted. This usually takes 2-3 minutes. - name: Set up Cloud SDK uses: google-github-actions/setup-gcloud@v2 @@ -64,10 +57,10 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: Update comment with tear-down status - if: steps.find-comment.outputs.comment-id != '' - uses: peter-evans/create-or-update-comment@v4 + uses: mshick/add-pr-comment@v2 with: - comment-id: ${{ steps.find-comment.outputs.comment-id }} - body: | - :broom: Preview environment for this PR has been torn down. - edit-mode: replace + repo-token: ${{ secrets.GITHUB_TOKEN }} + message-id: preview-env-status + refresh-message-position: true + message: | + :broom: Preview environment for this PR has been torn down. From 9bf63c0c2baeac9d313263659d4293c56d4da0a4 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Wed, 24 Jul 2024 13:45:07 +0200 Subject: [PATCH 2/4] subsequent push --- .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 9a857aa871..cdf8442792 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -99,4 +99,4 @@ jobs: message-id: preview-env-status refresh-message-position: true message: | - The preview environment relating to the commit ${{ github.sha }} has successfully been deployed. You can access it at [https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html](https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html). + The preview environment relating to the commit ${{ github.sha }} has successfully been deployed. You can access it at [https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html](https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html) From c499bbe52a4877b683e21d93a5ed6feec82a6077 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Wed, 24 Jul 2024 20:13:48 +0200 Subject: [PATCH 3/4] removed token --- .github/workflows/preview-env-deploy.yml | 3 --- .github/workflows/preview-env-teardown.yml | 2 -- 2 files changed, 5 deletions(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index cdf8442792..e8ddcfbfe7 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -31,7 +31,6 @@ jobs: - name: Upsert comment with build status uses: mshick/add-pr-comment@v2 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} message-id: preview-env-status refresh-message-position: true message: | @@ -69,7 +68,6 @@ jobs: - name: Update comment with upload status uses: mshick/add-pr-comment@v2 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} message-id: preview-env-status refresh-message-position: true message: | @@ -95,7 +93,6 @@ jobs: env: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} with: - repo-token: ${{ secrets.GITHUB_TOKEN }} message-id: preview-env-status refresh-message-position: true message: | diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml index 168840f39d..09dd943c31 100644 --- a/.github/workflows/preview-env-teardown.yml +++ b/.github/workflows/preview-env-teardown.yml @@ -32,7 +32,6 @@ jobs: - name: Update comment with tear-down warning uses: mshick/add-pr-comment@v2 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} message-id: preview-env-status refresh-message-position: true message: | @@ -59,7 +58,6 @@ jobs: - name: Update comment with tear-down status uses: mshick/add-pr-comment@v2 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} message-id: preview-env-status refresh-message-position: true message: | From 1c982d378336823c5a8c9905537701741b5191bf Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Wed, 24 Jul 2024 21:05:17 +0200 Subject: [PATCH 4/4] removed token --- .github/workflows/preview-env-deploy.yml | 3 --- .github/workflows/preview-env-teardown.yml | 2 -- 2 files changed, 5 deletions(-) diff --git a/.github/workflows/preview-env-deploy.yml b/.github/workflows/preview-env-deploy.yml index e8ddcfbfe7..b26c86b0d1 100644 --- a/.github/workflows/preview-env-deploy.yml +++ b/.github/workflows/preview-env-deploy.yml @@ -31,7 +31,6 @@ jobs: - name: Upsert comment with build status uses: mshick/add-pr-comment@v2 with: - message-id: preview-env-status refresh-message-position: true message: | :construction: The preview environment for the commit ${{ github.sha }} is being built. This usually takes 15-20 minutes. @@ -68,7 +67,6 @@ jobs: - name: Update comment with upload status uses: mshick/add-pr-comment@v2 with: - message-id: preview-env-status refresh-message-position: true message: | :arrow_up: The preview environment build results for commit ${{ github.sha }} are being uploaded. This usually takes 3-4 minutes. @@ -93,7 +91,6 @@ jobs: env: BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} with: - message-id: preview-env-status refresh-message-position: true message: | The preview environment relating to the commit ${{ github.sha }} has successfully been deployed. You can access it at [https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html](https://${{ env.BUCKET_NAME }}/pr-${{ github.event.number }}/index.html) diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml index 09dd943c31..bc8b147dc9 100644 --- a/.github/workflows/preview-env-teardown.yml +++ b/.github/workflows/preview-env-teardown.yml @@ -32,7 +32,6 @@ jobs: - name: Update comment with tear-down warning uses: mshick/add-pr-comment@v2 with: - message-id: preview-env-status refresh-message-position: true message: | :warning: Preview environment for commit ${{ github.sha }} is being deleted. This usually takes 2-3 minutes. @@ -58,7 +57,6 @@ jobs: - name: Update comment with tear-down status uses: mshick/add-pr-comment@v2 with: - message-id: preview-env-status refresh-message-position: true message: | :broom: Preview environment for this PR has been torn down.