name: Publish playground to GitHub pages

on:
  workflow_dispatch

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

    steps:
    - uses: actions/checkout@v4

    - uses: actions/setup-node@v4
      with:
        node-version: 18

    - name: build
      run: |
        npm i
        npm run build
      working-directory: src/playground

    - name: Deploy to GitHub Pages
      if: success()
      uses: crazy-max/ghaction-github-pages@v4
      with:
        target_branch: gh-pages
        build_dir: src/playground/dist
        jekyll: false
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
