name: Deploy

on:
  push:
    branches:
      - main

  workflow_dispatch:

jobs:
  deployment:
    name: Deploy site
    runs-on: ubuntu-latest

    steps:
      - name: checkout code repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Install pnpm
        uses: pnpm/action-setup@v2

      - name: Setup node version
        uses: actions/setup-node@v2
        with:
          node-version: 18
          cache: 'pnpm'

      - run: pnpm install
      # build all the packages
      - run: pnpm build
      # build the nextjs example
      - run: pnpm export

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          publish_dir: ./site/out
