name: Deploy to Github Pages
on:
  push:
    branches:
      - master
jobs:
  Build-Storybook:
    uses: ./.github/workflows/build.yml
  Deploy-Storybook:
    runs-on: ubuntu-latest
    if: ${{ success() }}
    needs: Build-Storybook
    steps:
      - name: Check out repository code
        uses: actions/checkout@v2
      - name: Download Storybook Assets
        # If closing PR, build will not occur so nothing to download
        if: github.event.action != 'closed'
        uses: actions/download-artifact@v4
        with:
          name: storybook-assets
          path: ./_site
      - name: Deploy 🚀
        uses: JamesIves/github-pages-deploy-action@v4.2.3
        with:
          branch: gh-pages
          folder: _site
          clean-exclude: pr-preview/
          force: false
