build_offline_docs.yml 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. timeout-minutes: 180
  15. strategy:
  16. max-parallel: 1
  17. fail-fast: false
  18. matrix:
  19. branch:
  20. - master
  21. - stable
  22. - 3.6
  23. permissions:
  24. contents: write
  25. steps:
  26. - uses: actions/checkout@v4
  27. with:
  28. ref: ${{ matrix.branch }}
  29. - name: Get Python version
  30. id: pythonv
  31. run: |
  32. echo "PYTHON_VERSION=$(python --version)" >> $GITHUB_OUTPUT
  33. - name: Restore cached virtualenv
  34. uses: actions/cache/restore@v4
  35. with:
  36. key: venv-${{ runner.os }}-${{ steps.pythonv.outputs.PYTHON_VERSION }}-${{ hashFiles('requirements.txt') }}
  37. path: .venv
  38. - name: Install dependencies
  39. run: |
  40. python -m venv .venv
  41. source .venv/bin/activate
  42. python -m pip install -r requirements.txt
  43. echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
  44. echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
  45. sudo apt update
  46. sudo apt install parallel libwebp7 imagemagick
  47. - name: Save virtualenv cache
  48. uses: actions/cache/save@v4
  49. with:
  50. key: venv-${{ runner.os }}-${{ steps.pythonv.outputs.PYTHON_VERSION }}-${{ hashFiles('requirements.txt') }}
  51. path: .venv
  52. - name: Sphinx - Build HTML
  53. run: make SPHINXOPTS='--color -j 4' html
  54. - uses: actions/upload-artifact@v4
  55. with:
  56. name: godot-docs-html-${{ matrix.branch }}
  57. path: _build/html
  58. # Keep the current build and the previous build (in case a scheduled build failed).
  59. # This makes it more likely to have at least one successful build available at all times.
  60. retention-days: 15
  61. - name: Sphinx - Build ePub
  62. run: |
  63. # Convert WebP images to PNG and replace references, so that ePub readers can display those images.
  64. # The ePub 3.0 specification has WebP support, but it's not widely supported by apps and e-readers yet.
  65. shopt -s globstar nullglob
  66. parallel --will-cite convert {} {.}.png ::: {about,community,contributing,getting_started,img,tutorials}/**/*.webp
  67. parallel --will-cite sed -i "s/\\.webp$/\\.png/g" ::: {about,community,contributing,getting_started,tutorials}/**/*.rst
  68. # Remove banners at the top of each page when building `latest`.
  69. sed -i 's/"godot_is_latest": True/"godot_is_latest": False/' conf.py
  70. sed -i 's/"godot_show_article_status": True/"godot_show_article_status": False/' conf.py
  71. make SPHINXOPTS='--color -j 4' epub
  72. - uses: actions/upload-artifact@v4
  73. with:
  74. name: godot-docs-epub-${{ matrix.branch }}
  75. path: _build/epub/GodotEngine.epub
  76. # Keep the current build and the previous build (in case a scheduled build failed).
  77. # This makes it more likely to have at least one successful build available at all times.
  78. retention-days: 15