deploy-docs.yml 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. name: Deploy Doc Site
  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: write
  12. steps:
  13. - uses: actions/checkout@v3
  14. with:
  15. fetch-depth: 2
  16. - name: Check if branch is main
  17. run: |
  18. if [ "$GITHUB_REF" != "refs/heads/gh-pages" ]; then
  19. echo "Not on gh-pages branch, exiting workflow."
  20. exit 0
  21. fi
  22. echo "On gh-pages branch, continuing workflow."
  23. - name: Config Git User
  24. run: |
  25. git config --local user.name "dragooncjw"
  26. git config --local user.email "289056872@qq.com"
  27. - uses: actions/setup-node@v3
  28. with:
  29. node-version: 18
  30. registry-url: 'https://registry.npmjs.org/'
  31. - name: Rush Install
  32. run: node common/scripts/install-run-rush.js install
  33. - name: Rush build
  34. run: node common/scripts/install-run-rush.js build
  35. - name: Generate docs
  36. run: |
  37. cd apps/docs
  38. npm run docs
  39. - name: Copy auto-docs to en
  40. run: cp -r apps/docs/src/zh/auto-docs apps/docs/src/en/auto-docs
  41. - name: Build Doc site
  42. run: |
  43. cd apps/docs
  44. npm run build
  45. - name: Replace docs
  46. run: |
  47. rm -rf docs
  48. mv apps/docs/doc_build docs
  49. - name: Push code
  50. env:
  51. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  52. run: |
  53. git add .
  54. git commit -m "chore: update docs" -n
  55. git push