feat: add documentation system with Docus framework #1
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
| # 部署文档站点到 GitHub Pages | |
| name: Deploy Docs to Pages | |
| # 触发条件 | |
| on: | |
| # 推送到 main 分支且 docs 目录有变更时触发 | |
| push: | |
| branches: [main] | |
| paths: | |
| - "docs/**" | |
| # PR 到 main 分支且 docs 目录有变更时触发(仅构建,不部署) | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - "docs/**" | |
| # 允许手动触发 | |
| workflow_dispatch: | |
| # 设置 GitHub Pages 部署所需的权限 | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # 只允许一个并发部署 | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| # 构建任务 | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('docs/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Install dependencies | |
| run: pnpm install | |
| working-directory: docs | |
| - name: Build | |
| run: pnpm run generate | |
| working-directory: docs | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: docs/.output/public | |
| # 部署任务 | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| needs: build | |
| if: github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |