Documentation #8
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: Documentation | |
| on: | |
| # 手动触发 | |
| workflow_dispatch: | |
| # 可选:PR 时构建但不部署(用于验证) | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - 'docs/**' | |
| - '.github/workflows/docs.yml' | |
| - 'rspress.config.ts' | |
| env: | |
| NODE_VERSION: '20' | |
| jobs: | |
| # ========== 构建文档 ========== | |
| build: | |
| name: Build Documentation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: false | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| version: 9 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile --ignore-scripts | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install wasm-pack | |
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| - name: Build qrcode-wasm | |
| run: pnpm --filter @veaba/qrcode-wasm exec npm run build | |
| - name: Build documentation | |
| run: pnpm docs:build | |
| - name: Upload documentation artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: documentation | |
| path: doc_build | |
| # ========== 部署到 Cloudflare Pages ========== | |
| deploy: | |
| name: Deploy to Cloudflare Pages | |
| runs-on: ubuntu-latest | |
| needs: build | |
| # 只在手动触发时部署 | |
| if: github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Download documentation artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: documentation | |
| path: doc_build | |
| - name: Deploy to Cloudflare Pages | |
| uses: cloudflare/pages-action@v1 | |
| with: | |
| apiToken: ${{ secrets.CF_API_TOKEN }} | |
| accountId: ${{ secrets.CF_ACCOUNT_ID }} | |
| projectName: qrcodes-docs | |
| directory: doc_build | |
| gitHubToken: ${{ secrets.GITHUB_TOKEN }} |