|
| 1 | +name: build |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [ main, develop, gh-build ] |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + |
| 9 | +jobs: |
| 10 | + # runs on weblate commit |
| 11 | + weblate-commit-build: |
| 12 | + if: ${{ contains(github.event.head_commit.message, 'Translated using Weblate') }} |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: TODO - start full build (delayed) |
| 16 | + run: echo "TODO - start delayed full build, maybe 15mins?" |
| 17 | + |
| 18 | + # on regular commit (auto excludes self-commited pot/po files) |
| 19 | + full-build: |
| 20 | + if: ${{ ! contains(github.event.head_commit.message, 'Translated using Weblate') }} |
| 21 | + concurrency: |
| 22 | + group: ${{ github.ref }} |
| 23 | + cancel-in-progress: true |
| 24 | + |
| 25 | + runs-on: ubuntu-latest |
| 26 | + container: |
| 27 | + image: sphinxdoc/sphinx |
| 28 | + #options: --user 1001 (only if we don't need apt-get) |
| 29 | + |
| 30 | + env: |
| 31 | + MAIN_LANGS: en |
| 32 | + OTHER_LANGS: de es fr ru nl it ja el bg da et fi lv lt pl pt ro sv sk sl cs hu zh_CN |
| 33 | + |
| 34 | + steps: |
| 35 | + - name: Install git |
| 36 | + run: | |
| 37 | + apt-get -y update |
| 38 | + apt-get -y install git ssh curl |
| 39 | + |
| 40 | + - name: Checkout |
| 41 | + uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - name: additional python packages |
| 44 | + run: pip3 install -r requirements.txt |
| 45 | + |
| 46 | + - name: quick build docs |
| 47 | + run: | |
| 48 | + mkdir -p dist/en |
| 49 | + mkdir -p build/en/doctrees |
| 50 | + sphinx-build -j auto -b html -D language=en -d build/en/doctrees source dist/en |
| 51 | + # remove/cleanup dist/en/_sources |
| 52 | +
|
| 53 | + - name: upload quick build artifact |
| 54 | + id: upload-quick |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: generated documentation (en) |
| 58 | + path: dist |
| 59 | + |
| 60 | + - name: trigger docs server to download artifact |
| 61 | + |
| 62 | + with: |
| 63 | + host: ${{ secrets.DOCS_HOST }} |
| 64 | + username: docs |
| 65 | + port: ${{ secrets.DOCS_PORT }} |
| 66 | + key: ${{ secrets.DEPLOY_AUTH_KEY }} |
| 67 | + script: /var/www/docs/deploy/github-trigger.sh en ${{ steps.upload-quick.outputs.artifact-id }} ${{ secrets.DOWNLOAD_TOKEN }} |
| 68 | + |
| 69 | + - name: build pot files |
| 70 | + run: sphinx-build -b gettext source locales/ |
| 71 | + |
| 72 | + - name: build po files from pot files |
| 73 | + shell: bash |
| 74 | + run: | |
| 75 | + lang=($OTHER_LANGS) |
| 76 | + sphinx-intl update -p locales/ ${lang[@]/*/'-l '&' '} |
| 77 | +
|
| 78 | + - name: prepare commit into self |
| 79 | + run: | |
| 80 | + cp -r locales locales.full |
| 81 | + rm -rf locales/.doctrees |
| 82 | +
|
| 83 | + - name: commit `locales` into repository (on changes) |
| 84 | + shell: bash |
| 85 | + run: | |
| 86 | + # not needed if run on --user 1001 |
| 87 | + git config --global --add safe.directory $(pwd) |
| 88 | + git config --global user.name "GitHub Action" |
| 89 | + git config --global user.email "[email protected]" |
| 90 | + if (git commit -m "Automated locales generation" locales); then |
| 91 | + git push |
| 92 | + fi |
| 93 | +
|
| 94 | + - name: put original `locales` back |
| 95 | + run: | |
| 96 | + rm -rf locales |
| 97 | + cp -r locales.full locales |
| 98 | +
|
| 99 | + - name: TODO - weblate |
| 100 | + run: | |
| 101 | + echo "trigger pull" |
| 102 | + echo "trigger deepl" |
| 103 | + echo "trigger commit" |
| 104 | + echo "trigger push" |
| 105 | +
|
| 106 | + - name: build full docs |
| 107 | + run: | |
| 108 | + cp -r locales source/locales |
| 109 | + for lang in $MAIN_LANGS $OTHER_LANGS |
| 110 | + do |
| 111 | + mkdir -p dist/$lang |
| 112 | + mkdir -p build/$lang/doctrees |
| 113 | + sphinx-build -j auto -b html -D language=$lang -d build/$lang/doctrees source dist/$lang |
| 114 | + # remove/cleanup dist/$lang/_sources |
| 115 | + done |
| 116 | +
|
| 117 | + - name: upload full build artifact |
| 118 | + id: upload-full |
| 119 | + uses: actions/upload-artifact@v4 |
| 120 | + with: |
| 121 | + name: generated documentation (all) |
| 122 | + path: dist |
| 123 | + |
| 124 | + - name: trigger docs server to download (FULL) artifact |
| 125 | + |
| 126 | + with: |
| 127 | + host: ${{ secrets.DOCS_HOST }} |
| 128 | + username: docs |
| 129 | + port: ${{ secrets.DOCS_PORT }} |
| 130 | + key: ${{ secrets.DEPLOY_AUTH_KEY }} |
| 131 | + script: /var/www/docs/deploy/github-trigger.sh en ${{ steps.upload-full.outputs.artifact-id }} ${{ secrets.DOWNLOAD_TOKEN }} |
| 132 | + |
| 133 | + |
| 134 | + |
0 commit comments