Merge pull request #121 from winjs-dev/dependabot/npm_and_yarn/rslib/… #7
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: Deploy Docs | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - refactor/rslib | |
| paths: | |
| - 'docs/**' | |
| - 'src/**' | |
| - 'rspress.config.ts' | |
| - 'package.json' | |
| workflow_dispatch: | |
| # 当有新的 release 时也触发文档部署 | |
| release: | |
| types: [published] | |
| jobs: | |
| deploy-docs: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # 确保同一时间只有一个部署在运行 | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| steps: | |
| - name: 检出代码 | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: 设置 Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: '22' | |
| - name: 安装 pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: 获取 pnpm store 目录 | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: 设置 pnpm 缓存 | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: 安装依赖 | |
| run: | | |
| # 尝试使用 frozen lockfile,如果失败则更新 lockfile | |
| pnpm install --frozen-lockfile || { | |
| echo "⚠️ Lockfile 不匹配,正在更新..." | |
| pnpm install --no-frozen-lockfile | |
| } | |
| - name: 构建项目 (生成类型定义) | |
| run: pnpm run build | |
| - name: 构建文档 | |
| run: pnpm run docs:build | |
| env: | |
| NODE_ENV: production | |
| - name: 设置 Pages | |
| uses: actions/configure-pages@v5 | |
| - name: 上传文档构建产物 | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: ./doc_build | |
| - name: 部署到 GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| - name: 通知部署成功 | |
| run: | | |
| echo "📚 文档部署成功!" | |
| echo "🌐 访问地址: ${{ steps.deployment.outputs.page_url }}" | |
| echo "📝 部署 ID: ${{ steps.deployment.outputs.deployment_id }}" |