From 4c6c0ad3088ee142b194120f13790457852a472c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Couto?= Date: Sat, 14 Dec 2024 18:17:22 +0000 Subject: [PATCH] fix: remove the deployed storybook when the PR is closed (#11) # Description - Add on-pull-request-close workflow ## Reason The deployment only runs when the build ran previously. However we need to run the deployment step when the PR is closed in order to clean up the deployed storybook, without having to run the build step again. --- --- .github/workflows/on-pull-request-close.yml | 18 ++++++++++++++++++ .github/workflows/on-pull-request.yml | 3 +-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/on-pull-request-close.yml diff --git a/.github/workflows/on-pull-request-close.yml b/.github/workflows/on-pull-request-close.yml new file mode 100644 index 0000000..3e1f1e0 --- /dev/null +++ b/.github/workflows/on-pull-request-close.yml @@ -0,0 +1,18 @@ +name: Feature Branch + +on: + pull_request: + types: + - closed + +concurrency: preview-${{ github.ref }} + +jobs: + clean-deployment: + if: github.event.action == 'closed' && github.event.pull_request.draft == false + runs-on: ubuntu-20.04 + steps: + - name: Deploy preview + uses: rossjrw/pr-preview-action@v1 + with: + custom-url: percoct-ui.yld.engineering diff --git a/.github/workflows/on-pull-request.yml b/.github/workflows/on-pull-request.yml index 891fdaf..cf907f7 100644 --- a/.github/workflows/on-pull-request.yml +++ b/.github/workflows/on-pull-request.yml @@ -26,6 +26,7 @@ jobs: deployment: runs-on: ubuntu-20.04 needs: ["build"] + if: github.event.action != 'closed' && github.event.pull_request.draft == false environment: name: github-pages url: ${{ steps.preview.outputs.deployment-url }} @@ -33,13 +34,11 @@ jobs: environment_url: ${{ steps.preview.outputs.deployment-url }} steps: - name: Checkout - if: github.event.action != 'closed' && github.event.pull_request.draft == false uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/download-artifact@v4 - if: github.event.action != 'closed' && github.event.pull_request.draft == false with: name: storybook-static path: ./storybook-static/