Skip to content

Commit c52412c

Browse files
committed
Add ci job for pushing/pulling content to Transifex
Add two wrapper scripts in _utils for that.
1 parent 7265de4 commit c52412c

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

.gitlab-ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,38 @@ include:
22
- project: 'QubesOS/qubes-continuous-integration'
33
file: '/gitlab-website.yml'
44

5+
stages:
6+
- prepare
7+
- build
8+
59
build:website:
610
extends: .website
11+
12+
update-transifex:
13+
tags:
14+
- docker
15+
stage: prepare
16+
rules:
17+
- if: '$TX_TOKEN && $GITHUB_KEY'
18+
when: always
19+
- when: never
20+
variables:
21+
GIT_SUBMODULE_STRATEGY: normal
22+
GIT_AUTHOR_NAME: translation bot
23+
GIT_AUTHOR_EMAIL: [email protected]
24+
GIT_COMMITTER_NAME: translation bot
25+
GIT_COMMITTER_EMAIL: [email protected]
26+
TRANSLATED_LANGS: de fr es
27+
LANG: C.UTF-8
28+
before_script:
29+
- mkdir -p $HOME/.ssh && echo "$GITHUB_KEY" > $HOME/.ssh/id_ed25519 && chmod 700 $HOME/.ssh/id_ed25519
30+
- echo "github.com,140.82.121.4 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> $HOME/.ssh/known_hosts
31+
- export PATH=$PATH:$HOME/bin
32+
- sudo dnf install -y python3-pycurl python3-PyYAML python3-jsonschema python3-certifi python3-attrs /usr/bin/bundle rubygem-jekyll rubygem-nokogiri rubygem-concurrent-ruby ruby-devel gcc-c++ transifex-client crudini python3-pycurl python3-pyrsistent
33+
- pip install python-frontmatter
34+
- export NOKOGIRI_USE_SYSTEM_LIBRARIES=true
35+
- gem install github-pages json html-proofer
36+
- git submodule update --init
37+
script:
38+
- _utils/transifex-push
39+
- _utils/transifex-pull $TRANSLATED_LANGS

_utils/transifex-pull

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/sh
2+
3+
# Pull translated pages from Transifex
4+
5+
if ! command -v tx; then
6+
echo "transifex-client needs to be installed" >&2
7+
exit 1
8+
fi
9+
10+
if [ -z "$TX_TOKEN" ]; then
11+
echo "Please set TX_TOKEN variable to Transifex API key" >&2
12+
exit 1
13+
fi
14+
15+
if [ -z "$1" ]; then
16+
echo "Usage: $0 <lang> [<lang> ...]"
17+
fi
18+
19+
set -e
20+
21+
for lang in "$@"; do
22+
bash _utils/_translation_utils/tx_pull.sh "$lang"
23+
bash _utils/_translation_utils/post_transifex_pull.sh "$lang" _translated/"$lang"
24+
done
25+
26+
# switch to ssh for push
27+
git -C _translated remote set-url origin [email protected]:QubesOS/qubes-translated
28+
29+
# commit and push
30+
git -C _translated add .
31+
32+
# if nothing to commit, exit early
33+
[ -n "$(git -C _translated status --porcelain)" ] || exit 0
34+
35+
git -C _translated commit -m 'Update translated content'
36+
git -C _translated push origin HEAD:master

_utils/transifex-push

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
# This script uploads the website source files to Transifex for translation, including all the preparatory work
4+
5+
if ! command -v tx; then
6+
echo "transifex-client needs to be installed" >&2
7+
exit 1
8+
fi
9+
10+
if [ -z "$TX_TOKEN" ]; then
11+
echo "Please set TX_TOKEN variable to Transifex API key" >&2
12+
exit 1
13+
fi
14+
15+
set -e
16+
17+
# update config
18+
bash _utils/_translation_utils/tx_config.sh
19+
20+
# push the sources
21+
tx push -s
22+
23+
# update sources metadata (notranslate tags, locks etc)
24+
bash _utils/_translation_utils/prepare_tx_config_for_notranslate_tags.sh .tx/config /tmp/tx-resources-names.txt /tmp/tx-sources-filenames.txt
25+
python3 _utils/_translation_utils/tag_strings_as_locked.py /tmp/tx-resources-names.txt /tmp/tx-sources-filenames.txt --debug
26+
27+

0 commit comments

Comments
 (0)