name: 部署文档

on:
  push:
    branches:
      - main
    paths:
      - .github/**
      - src/**
      - docs/**
      - public/**
      - package.json
      - vuepress.*.ts
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

permissions:
  contents: write
  statuses: write

env:
  MELI_SITE: b9bc0b87-f062-4724-b2f5-55866ff12736

jobs:
  build:
    runs-on: [ubuntu-latest, liteyuki]
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          # lfs: true
          # 如果你文档需要 Git 子模块，取消注释下一行
          # submodules: true

      - name: 设置 pnpm
        uses: pnpm/action-setup@v4
        # with:
        #   version: 8


      - name: 设置 Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 23
          cache: pnpm

      - name: 安装依赖
        run: |
          corepack enable
          pnpm install --frozen-lockfile

      - name: 构建文档
        env:
          NODE_OPTIONS: --max_old_space_size=8192
        run: |-
          pnpm run build
          > dist/.nojekyll

      - name: 推送 liteyuki pages
        run: |
          pnpx @getmeli/cli upload \
            --branch main \
            --url "https://dash.apage.dev" \
            --site "$MELI_SITE" \
            --token "$MELI_TOKEN" \
            --release "$GITHUB_SHA" \
            ./dist
        env:
          MELI_TOKEN: ${{ secrets.MELI_TOKEN }}
          # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
