name: deploying-doc
run-name: Deploying doc — ${{ gitea.run_id }}
on:
  workflow_dispatch:
  schedule:
    - cron: 30 04 * * 1,4

jobs:
  build-and-deploy:
      runs-on: ubuntu-latest
      permissions:
        contents: read
        deployments: write
      steps:
          - name: 🚚 Checkout
            uses: actions/checkout@v4
            with:
              fetch-depth: 0

          - name: 🔧Install Node.js
            uses: actions/setup-node@v4
            with:
              node-version: 20
              cache: 'npm'

          - name: 🔧Install dependencies
            run: npm install

          - name: 🔴Build doc
            run: npm run docs:build
            
          - name: 🚀 Deploy to Cloudflare Pages
            uses: cloudflare/wrangler-action@v3
            with:
              apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
              accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
              command: pages deploy ./src/.vuepress/dist --project-name=jingji-spbook-vue
