From a7ab6364c5d1a422b257b35e7c485038418301c8 Mon Sep 17 00:00:00 2001 From: Andromachi Rozaki Date: Wed, 19 Jun 2024 18:00:51 +0200 Subject: [PATCH] reverted changes in teardown workflow --- .github/workflows/preview-env-teardown.yml | 32 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/preview-env-teardown.yml b/.github/workflows/preview-env-teardown.yml index 2c4bef78f4f..158c34be562 100644 --- a/.github/workflows/preview-env-teardown.yml +++ b/.github/workflows/preview-env-teardown.yml @@ -1,9 +1,11 @@ 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 @@ -30,11 +32,29 @@ jobs: - name: Set up Cloud SDK uses: google-github-actions/setup-gcloud@v2 - # 124 - - name: Delete comment + - name: Remove files from Google bucket env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }} run: | - var="Preview environment has successfully been deployed. You can access it on https://preview.docs.camunda.cloud/pr-3960/index.html." - response=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/camunda/camunda-docs/issues/comments) - echo "$response" | jq --arg body "$var" '.[] | select(.body == $body)' + 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