vitepress-deploy.yml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程
  2. #
  3. name: Deploy VitePress site to Pages
  4. on:
  5. push:
  6. branches: [main]
  7. # 允许你从 Actions 选项卡手动运行此工作流程
  8. workflow_dispatch:
  9. # 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
  10. permissions:
  11. contents: read
  12. pages: write
  13. id-token: write
  14. # 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
  15. # 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
  16. concurrency:
  17. group: pages
  18. cancel-in-progress: false
  19. jobs:
  20. # 构建工作
  21. build:
  22. runs-on: ubuntu-latest
  23. steps:
  24. - name: Checkout
  25. uses: actions/checkout@v4
  26. with:
  27. fetch-depth: 0 # 如果未启用 lastUpdated,则不需要
  28. - uses: pnpm/action-setup@v3 # 如果使用 pnpm,请取消此区域注释
  29. with:
  30. version: 9
  31. - name: Setup Node
  32. uses: actions/setup-node@v4
  33. with:
  34. node-version: 18
  35. cache: pnpm
  36. - name: Setup Pages
  37. uses: actions/configure-pages@v4
  38. - name: Install dependencies
  39. run: pnpm i
  40. - name: Build with VitePress
  41. run: pnpm run docs:build
  42. - name: Upload artifact
  43. uses: actions/upload-pages-artifact@v3
  44. with:
  45. path: docs/.vitepress/dist
  46. # 部署工作
  47. deploy:
  48. environment:
  49. name: github-pages
  50. url: ${{ steps.deployment.outputs.page_url }}
  51. needs: build
  52. runs-on: ubuntu-latest
  53. name: Deploy
  54. steps:
  55. - name: Deploy to GitHub Pages
  56. id: deployment
  57. uses: actions/deploy-pages@v4