deploy-docs.yml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Workflow that builds and deploys the documentation website
  2. name: Deploy Docs to GitHub Pages
  3. # * Always run on "main"
  4. # * Run on PRs that target the "main" branch and have changes in the "docs" folder or this workflow
  5. on:
  6. push:
  7. branches:
  8. - main
  9. pull_request:
  10. paths:
  11. - 'docs/**'
  12. - '.github/workflows/deploy-docs.yml'
  13. branches:
  14. - main
  15. # If triggered by a PR, it will be in the same group. However, each commit on main will be in its own unique group
  16. concurrency:
  17. group: ${{ github.workflow }}-${{ (github.head_ref && github.ref) || github.run_id }}
  18. cancel-in-progress: true
  19. jobs:
  20. # Build the documentation website
  21. build:
  22. if: github.repository == 'All-Hands-AI/OpenHands'
  23. name: Build Docusaurus
  24. runs-on: ubuntu-latest
  25. steps:
  26. - uses: actions/checkout@v4
  27. with:
  28. fetch-depth: 0
  29. - uses: actions/setup-node@v4
  30. with:
  31. node-version: 18
  32. cache: npm
  33. cache-dependency-path: docs/package-lock.json
  34. - name: Set up Python
  35. uses: actions/setup-python@v5
  36. with:
  37. python-version: '3.12'
  38. - name: Generate Python Docs
  39. run: rm -rf docs/modules/python && pip install pydoc-markdown && pydoc-markdown
  40. - name: Install dependencies
  41. run: cd docs && npm ci
  42. - name: Build website
  43. run: cd docs && npm run build
  44. - name: Upload Build Artifact
  45. if: github.ref == 'refs/heads/main'
  46. uses: actions/upload-pages-artifact@v3
  47. with:
  48. path: docs/build
  49. # Deploy the documentation website
  50. deploy:
  51. if: github.ref == 'refs/heads/main' && github.repository == 'All-Hands-AI/OpenHands'
  52. name: Deploy to GitHub Pages
  53. runs-on: ubuntu-latest
  54. # This job only runs on "main" so only run one of these jobs at a time
  55. # otherwise it will fail if one is already running
  56. concurrency:
  57. group: ${{ github.workflow }}-${{ github.ref }}
  58. needs: build
  59. # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
  60. permissions:
  61. pages: write # to deploy to Pages
  62. id-token: write # to verify the deployment originates from an appropriate source
  63. # Deploy to the github-pages environment
  64. environment:
  65. name: github-pages
  66. url: ${{ steps.deployment.outputs.page_url }}
  67. steps:
  68. - name: Deploy to GitHub Pages
  69. id: deployment
  70. uses: actions/deploy-pages@v4