fix: 任意分支都可以测试 #114
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 # 在 working-directory 为 frontend 时,这是相对路径 | |
| 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 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: "pnpm" # 顺便启用 pnpm 缓存,加速 | |
| cache-dependency-path: frontend/pnpm-lock.yaml | |
| # 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 --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: . # git-auto-commit-action 建议在根目录运行以处理全局路径 | |
| - 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 |