Skip to content

Commit

Permalink
initial refactoring commit
Browse files Browse the repository at this point in the history
  • Loading branch information
daringer committed Nov 25, 2024
0 parents commit 5786fbe
Show file tree
Hide file tree
Showing 745 changed files with 1,053,001 additions and 0 deletions.
142 changes: 142 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: build
on:
push:
branches: [ main, develop, gh-build, fresh ]

permissions:
contents: write

jobs:
# runs on weblate commit
weblate-commit-build:
if: ${{ contains(github.event.head_commit.message, 'Translated using Weblate') }}
runs-on: ubuntu-latest
steps:
- name: TODO - start full build (delayed)
run: echo "TODO - start delayed full build, maybe 15mins?"

# on regular commit (auto excludes self-commited pot/po files)
full-build:
if: ${{ ! contains(github.event.head_commit.message, 'Translated using Weblate') }}
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: 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: build pot files
run: sphinx-build -b gettext source locales/

- name: build po files from pot files
shell: bash
run: |
lang=($OTHER_LANGS)
sphinx-intl update -p locales/ ${lang[@]/*/'-l '&' '}
- name: prepare commit into self
run: |
cp -r locales locales.full
rm -rf locales/.doctrees
- name: commit `locales` into repository (on changes)
shell: bash
run: |
# 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 locales generation" locales); then
git push
fi
- name: put original `locales` back
run: |
rm -rf locales
cp -r locales.full locales
- name: TODO - weblate
shell: bash
run: |
echo "trigger pull"
echo "trigger deepl"
echo "trigger commit"
echo "trigger push"
# for lang in $OTHER_LANGS
# do
# bash trigger_weblate.sh ${{ secrets.WEBLATE_API_URL }} $lang ${{ secrets.WEBLATE_TOKEN }}
# done
- name: build full docs
run: |
# one _images is enough
mv dist/en/_images dist
cp -r locales source/locales
for lang in $MAIN_LANGS $OTHER_LANGS
do
mkdir -p dist/$lang
mkdir -p build/$lang/doctrees
sphinx-build -j auto -b html -D language=$lang -d build/$lang/doctrees source dist/$lang
rm -rf dist/$lang/_sources dist/$lang/_images
done
- name: upload full build artifact
id: upload-full
uses: actions/upload-artifact@v4
with:
name: generated documentation (all)
path: dist

- name: trigger docs server to download (FULL) 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 all ${{ steps.upload-full.outputs.artifact-id }} ${{ secrets.DOWNLOAD_TOKEN }}



3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
dist
venv
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@



all: venv
venv/bin/sphinx-build -j auto -b html -D language=en -d build/en/doctrees source dist/en


venv:
python -m venv venv
venv/bin/pip3 install -r requirements.txt

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Nitrokey Documentation



### Local build

Be sure to have a recent python installed, then:

```
make
```

The (english) result is to be found in `dist/en`, to show run:
```
firefox dist/en/index.html
```
Loading

0 comments on commit 5786fbe

Please sign in to comment.