vitepress-deploy.yml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. name: Build and Deploy VitePress Site with Pnpm
  2. on:
  3. push:
  4. branches:
  5. - main # 你想要触发部署的分支名称
  6. # 你可以根据需要添加其他触发条件
  7. # Allows you to run this workflow manually from the Actions tab
  8. workflow_dispatch:
  9. # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
  10. permissions:
  11. contents: read
  12. pages: write
  13. id-token: write
  14. jobs:
  15. # Build job
  16. build:
  17. runs-on: ubuntu-latest # 运行环境
  18. steps:
  19. # 设置服务器时区为东八区
  20. - name: Set time zone
  21. run: sudo timedatectl set-timezone 'Asia/Shanghai'
  22. - uses: actions/checkout@v4
  23. - uses: pnpm/action-setup@v4
  24. with:
  25. version: 9
  26. - uses: actions/setup-node@v4
  27. with:
  28. node-version: '18'
  29. cache: 'pnpm'
  30. - name: Install dependencies
  31. run: pnpm i --no-frozen-lockfile
  32. - name: Build VitePress site with Pnpm
  33. run: pnpm run docs:build
  34. - name: Upload artifact
  35. uses: actions/upload-pages-artifact@v3
  36. with:
  37. path: ./docs/.vitepress/dist/
  38. # Deployment job
  39. deploy:
  40. environment:
  41. name: github-pages
  42. url: ${{ steps.deployment.outputs.page_url }}
  43. runs-on: ubuntu-latest
  44. needs: build
  45. steps:
  46. - name: Deploy to GitHub Pages
  47. id: deployment
  48. uses: actions/deploy-pages@v4