deploy.yml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. name: Deploy With Actions
  2. on:
  3. workflow_dispatch
  4. concurrency:
  5. group: "gh-pages-branch-workflow" # 唯一标识符,确保只运行一个实例
  6. cancel-in-progress: false # 不取消正在运行的实例,后续触发需要等待当前实例完成
  7. jobs:
  8. build:
  9. runs-on: ubuntu-latest
  10. permissions:
  11. contents: read
  12. pages: write
  13. id-token: write
  14. steps:
  15. - uses: actions/checkout@v3
  16. with:
  17. fetch-depth: 2
  18. - name: Check if branch is main
  19. run: |
  20. if [ "$GITHUB_REF" != "refs/heads/gh-pages" ]; then
  21. echo "Not on gh-pages branch, exiting workflow."
  22. exit 1
  23. fi
  24. echo "On gh-pages branch, continuing workflow."
  25. - name: Config Git User
  26. run: |
  27. git config --local user.name "dragooncjw"
  28. git config --local user.email "289056872@qq.com"
  29. - uses: actions/setup-node@v3
  30. with:
  31. node-version: 18
  32. registry-url: 'https://registry.npmjs.org/'
  33. - name: Rush Install
  34. run: node common/scripts/install-run-rush.js install
  35. - name: Rush build
  36. run: node common/scripts/install-run-rush.js build
  37. - name: Generate docs
  38. run: |
  39. cd apps/docs
  40. npm run docs
  41. - name: Copy auto-docs to en
  42. run: cp -r apps/docs/src/zh/auto-docs apps/docs/src/en/auto-docs
  43. - name: Build Doc site
  44. run: |
  45. cd apps/docs
  46. npm run build
  47. - name: Replace docs
  48. run: |
  49. rm -rf docs
  50. mv apps/docs/doc_build docs
  51. - name: Upload artifact
  52. uses: actions/upload-pages-artifact@v3
  53. with:
  54. path: docs
  55. name: github-pages
  56. deploy:
  57. permissions:
  58. contents: read
  59. pages: write
  60. id-token: write
  61. needs: build
  62. runs-on: ubuntu-latest
  63. environment:
  64. name: github-pages
  65. url: ${{ steps.deployment.outputs.page_url }}
  66. steps:
  67. - name: Deploy to GitHub Pages
  68. id: deployment
  69. uses: actions/deploy-pages@v4