build_offline_docs.yml 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. name: Build documentation for offline usage
  2. on:
  3. workflow_dispatch:
  4. schedule:
  5. # Every week on Monday at midnight (UTC).
  6. # This keeps the generated HTML documentation fresh.
  7. - cron: '0 0 * * 1'
  8. jobs:
  9. build:
  10. # Don't run scheduled runs on forks unless the CI_OFFLINE_DOCS_CRON variable is set to 'true'.
  11. # Manual runs can still be triggered as normal.
  12. if: ${{ github.repository_owner == 'godotengine' || github.event_name != 'schedule' || vars.CI_OFFLINE_DOCS_CRON == 'true' }}
  13. runs-on: ubuntu-24.04
  14. strategy:
  15. matrix:
  16. branch:
  17. - master
  18. - stable
  19. - 3.6
  20. permissions:
  21. contents: write
  22. steps:
  23. - uses: actions/checkout@v4
  24. with:
  25. ref: ${{ matrix.branch }}
  26. - name: Get Python version
  27. id: pythonv
  28. run: |
  29. echo "PYTHON_VERSION=$(python --version)" >> $GITHUB_OUTPUT
  30. - name: Restore cached virtualenv
  31. uses: actions/cache/restore@v4
  32. with:
  33. key: venv-${{ runner.os }}-${{ steps.pythonv.outputs.PYTHON_VERSION }}-${{ hashFiles('requirements.txt') }}
  34. path: .venv
  35. - name: Install dependencies
  36. run: |
  37. python -m venv .venv
  38. source .venv/bin/activate
  39. python -m pip install -r requirements.txt
  40. echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
  41. echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
  42. sudo apt update
  43. sudo apt install parallel libwebp7
  44. - name: Save virtualenv cache
  45. uses: actions/cache/save@v4
  46. with:
  47. key: venv-${{ runner.os }}-${{ steps.pythonv.outputs.PYTHON_VERSION }}-${{ hashFiles('requirements.txt') }}
  48. path: .venv
  49. - name: Sphinx - Build HTML
  50. run: make SPHINXOPTS='--color -j 4' html
  51. - uses: actions/upload-artifact@v4
  52. with:
  53. name: godot-docs-html-${{ matrix.branch }}
  54. path: _build/html
  55. # Keep the current build and the previous build (in case a scheduled build failed).
  56. # This makes it more likely to have at least one successful build available at all times.
  57. retention-days: 15
  58. - name: Sphinx - Build ePub
  59. run: |
  60. # Convert WebP images to PNG and replace references, so that ePub readers can display those images.
  61. # The ePub 3.0 specification has WebP support, but it's not widely supported by apps and e-readers yet.
  62. shopt -s globstar nullglob
  63. parallel --will-cite convert {} {.}.png ::: {about,community,contributing,getting_started,img,tutorials}/**/*.webp
  64. parallel --will-cite sed -i "s/\\.webp$/\\.png/g" ::: {about,community,contributing,getting_started,tutorials}/**/*.rst
  65. # Remove banners at the top of each page when building `latest`.
  66. sed -i 's/"godot_is_latest": True/"godot_is_latest": False/' conf.py
  67. sed -i 's/"godot_show_article_status": True/"godot_show_article_status": False/' conf.py
  68. make SPHINXOPTS='--color -j 4' epub
  69. - uses: actions/upload-artifact@v4
  70. with:
  71. name: godot-docs-epub-${{ matrix.branch }}
  72. path: _build/epub/GodotEngine.epub
  73. # Keep the current build and the previous build (in case a scheduled build failed).
  74. # This makes it more likely to have at least one successful build available at all times.
  75. retention-days: 15