Skip to content

ci: cleanup build.yml #57

ci: cleanup build.yml

ci: cleanup build.yml #57

Workflow file for this run

name: build
on:
push:
branches: [ main ]
jobs:
full-build:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
container:
image: sphinxdoc/sphinx
#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: Install git
run: |
apt-get -y update
apt-get -y install git ssh curl
- name: Checkout
uses: actions/checkout@v4
- name: Install additional python packages
run: pip3 install -r requirements.txt
- name: Quick build docs
run: |
mkdir -p dist/en
mkdir -p build/en/doctrees
sphinx-build -j auto -b html -D language=en -d build/en/doctrees source dist/en
rm -rf dist/en/_sources
- name: Upload quick build artifact
id: upload-quick
uses: actions/upload-artifact@v4
with:
name: generated documentation (en)
path: dist
- 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/github-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: sphinx-build -b gettext source data.git/locales/
- name: Build po files from pot files
shell: bash
run: |
lang=($OTHER_LANGS)
sphinx-intl update -p 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 generation" locales); then
git push
fi