name: Build and Deploy

on:
  push:
    branches:
      - master

jobs:
  build-and-publish-live-demo:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install and Build
        run: |
          npm install
          npm run build

      - name: Deploy
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          branch: demo
          folder: dist

  deploy-v3:
    runs-on: ubuntu-latest
    needs: build-and-publish-live-demo

    steps:
      - name: Checkout repository content
        uses: actions/checkout@v4

      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v4
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./v3
          publish_branch: demo
          destination_dir: v3
