Skip to content

Commit

Permalink
fix: remove the deployed storybook when the PR is closed (#11)
Browse files Browse the repository at this point in the history
# 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.

---

<!-- Auto-generated section. DO NOT DELETE -->
  • Loading branch information
Couto authored Dec 14, 2024
1 parent 4fba2cc commit 4c6c0ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/on-pull-request-close.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,19 @@ 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 }}
outputs:
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/
Expand Down

0 comments on commit 4c6c0ad

Please sign in to comment.