From 5c48f374ace3575c1936cd47027750c380e14de1 Mon Sep 17 00:00:00 2001 From: Ghislain Gabrielse Date: Mon, 10 Jun 2024 14:53:51 +0200 Subject: [PATCH] Add delete-preview.yml --- .github/workflows/delete-preview.yml | 44 ++++++++++++++++++++++++++++ .github/workflows/deploy-preview.yml | 1 + 2 files changed, 45 insertions(+) create mode 100644 .github/workflows/delete-preview.yml diff --git a/.github/workflows/delete-preview.yml b/.github/workflows/delete-preview.yml new file mode 100644 index 00000000000..408d7e10ccc --- /dev/null +++ b/.github/workflows/delete-preview.yml @@ -0,0 +1,44 @@ + +name: Remove deploy preview + +permissions: + contents: read + statuses: write + pull-requests: write + +env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_DOCS_ID }} + +on: + pull_request: + types: + - closed + +jobs: + delete-deployments: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + show-progress: false + + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + - name: Hash branch name + uses: pplanel/hash-calculator-action@v1.3.1 + id: hash_branch + with: + input: ${{ steps.extract_branch.outputs.branch }} + method: MD5 + + - name: Call the delete-deployment-preview.sh script + env: + META_TAG: ${{ steps.hash_branch.outputs.digest }} + run: | + bash ./scripts/delete-deployment-preview.sh \ No newline at end of file diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index 51bff406e8a..15aabbde654 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -60,5 +60,6 @@ jobs: run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} --archive=tgz | tee deploy.log - name: Set preview url + if: steps.detectChanges.outputs.changed == 'true' id: deployment run: echo "url=$(tail -1 deploy.log)">> $GITHUB_OUTPUT \ No newline at end of file