This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docs Backfill (on docs changes) | |
| on: | |
| push: | |
| branches: ["**"] | |
| paths: | |
| - "frontend/app/docs/**" | |
| - "frontend/scripts/uuid.mjs" | |
| - "frontend/scripts/backfill-contributors.mjs" | |
| - "frontend/package.json" | |
| - "frontend/pnpm-lock.yaml" | |
| - ".github/workflows/sync-uuid.yml" | |
| - "frontend/generated/doc-contributors.json" | |
| workflow_dispatch: {} | |
| concurrency: | |
| group: backfill-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| backfill: | |
| # 防止 fork 并避免机器人循环 | |
| if: github.actor != 'github-actions[bot]' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| defaults: | |
| run: | |
| working-directory: frontend | |
| env: | |
| DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
| GITHUB_TOKEN: ${{ secrets.GH_PAT }} # 供脚本调用 GitHub API 提升速率 | |
| DOCS_DIR: app/docs | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Enable corepack to ensure the exact pnpm version from package.json is used | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10.20.0 | |
| package_json_file: frontend/package.json | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| # 不再这里配置缓存,避免子目录解析错误 | |
| # Verify pnpm version matches package.json packageManager field | |
| - name: Check pnpm version | |
| run: node scripts/check-pnpm-version.mjs | |
| - name: Install deps | |
| run: pnpm install --no-frozen-lockfile | |
| - name: Generate Prisma Client | |
| run: pnpm prisma generate | |
| - name: Ensure docId frontmatter | |
| run: pnpm exec node scripts/uuid.mjs | |
| - name: Backfill contributors & sync DB | |
| run: pnpm exec tsx scripts/backfill-contributors.mjs | |
| - name: Auto-commit doc metadata (if any) | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: "chore(docs): sync doc metadata [skip ci]" # ← 防循环 | |
| file_pattern: "frontend/app/docs/**/*.md frontend/app/docs/**/*.mdx frontend/generated/doc-contributors.json" | |
| working_directory: . | |
| - name: Upload snapshot JSON | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: doc-contributors-snapshot | |
| path: frontend/generated/doc-contributors.json | |
| if-no-files-found: ignore |