small improvements (#367) #79
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
full-build: | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
runs-on: ubuntu-latest | |
container: | |
image: python:3.11 | |
#options: --user 1001 (only if we don't need apt-get) | |
env: | |
MAIN_LANGS: en | |
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 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Create virtual environment | |
run: make venv | |
- name: Quick build docs | |
run: | | |
make | |
cp -r redirects/.htaccess dist | |
- name: Upload quick build artifact | |
id: upload-quick | |
uses: actions/upload-artifact@v4 | |
with: | |
name: generated documentation (en) | |
path: dist | |
include-hidden-files: true | |
- name: Trigger docs server to download artifact | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.DOCS_HOST }} | |
username: docs | |
port: ${{ secrets.DOCS_PORT }} | |
key: ${{ secrets.DEPLOY_AUTH_KEY }} | |
script: /var/www/docs/deploy/gh-trigger.sh en ${{ steps.upload-quick.outputs.artifact-id }} ${{ secrets.DOWNLOAD_TOKEN }} | |
- name: Checkout data repository | |
uses: actions/checkout@v4 | |
with: | |
repository: nitrokey/nitrokey-documentation-data | |
ref: main | |
ssh-key: ${{ secrets.DEPLOY_AUTH_KEY }} | |
path: data.git | |
- name: Build pot files | |
run: venv/bin/sphinx-build -b gettext source data.git/locales/ | |
- name: Build po files from pot files | |
shell: bash | |
run: | | |
lang=($OTHER_LANGS) | |
venv/bin/sphinx-intl update -p data.git/locales/ -d data.git/locales/ ${lang[@]/*/'-l '&' '} | |
rm -rf data.git/locales/.doctrees | |
# this one looks like a upstream bug for the auto-translation | |
# we will replace all backslashes '\\' with '/bs/' and revert | |
# this operation before actually building the language | |
# let's hope this works | |
- name: WORKAROUND - replace double backslashes in .po files | |
shell: bash | |
run: | | |
sed -ie 's@\\\\@/bs/@g' $(find data.git/locales -name "*.po" | xargs) | |
- name: commit `locales` into data repository (on changes) | |
shell: bash | |
run: | | |
cd data.git | |
# not needed if run on --user 1001 | |
git config --global --add safe.directory $(pwd) | |
git config --global user.name "GitHub Action" | |
git config --global user.email "[email protected]" | |
if (git commit -m "Automated .pot/.po generation" locales); then | |
git push | |
fi |