name: Deploy demo website

on:
  workflow_dispatch:
  release:
    types: [created]

jobs:
  deploy:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node: [16.x]
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Use Node.js ${{ matrix.node }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node }}

      - name: Install
        run: |
          npm install
      - name: Build
        run: |
          npm run build:demo
      - name: Deploy public to gh-pages repo
        if: success()
        uses: crazy-max/ghaction-github-pages@v3
        with:
          target_branch: gh-pages
          build_dir: public
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
