Merge branch '2.0' #6
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 | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 使用 git clone 替代 actions/checkout(适配仅允许组织内 actions 的策略) | |
| - name: 获取代码 | |
| run: | | |
| git clone --branch ${{ github.ref_name }} https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git . | |
| - name: 设置 pnpm | |
| run: | | |
| corepack enable | |
| corepack prepare pnpm@9 --activate | |
| # ubuntu-latest 自带 Node.js 20,如需 Node 22 可取消下行注释 | |
| # - run: npx -y n 22 && npm cache clean -f | |
| - name: 安装依赖 | |
| run: pnpm install --frozen-lockfile | |
| - name: 构建 VuePress 站点 | |
| run: pnpm docs:build | |
| # 使用 git 命令替代 crazy-max/ghaction-github-pages | |
| - name: 部署到 GitHub Pages | |
| run: | | |
| cd docs/.vuepress/dist | |
| git init | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| git commit -m "Deploy from GitHub Actions" | |
| git branch -M main | |
| git push -f https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git main:gh-pages |