-
Notifications
You must be signed in to change notification settings - Fork 22
51 lines (44 loc) · 1.5 KB
/
i18n-extract.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Extract i18n Strings
on:
push:
branches:
- master
paths:
- '**/*.py'
- '!**/tests/**'
jobs:
extract_strings:
runs-on: ubuntu-latest
env:
PYGETTEXT_DOMAIN: ardupilot_methodic_configurator
PYGETTEXT_LOCALEDIR: ardupilot_methodic_configurator/locale
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install requirements
run: |
python -m pip install --upgrade pip python-gettext
- name: Extract strings
run: |
pygettext3 -d $PYGETTEXT_DOMAIN -o $PYGETTEXT_LOCALEDIR/$PYGETTEXT_DOMAIN.pot $(git ls-files '*.py') || exit 1
- name: Commit changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add $PYGETTEXT_LOCALEDIR/$PYGETTEXT_DOMAIN.pot
if [ -n "$(git status --porcelain)" ]; then
CHANGED_LINES=$(git diff --staged | grep -E "^[\+\-]" | wc -l)
if [ $CHANGED_LINES -gt 4 ]; then
git commit -m "CHORE: Extracted i18n strings to $PYGETTEXT_LOCALEDIR/$PYGETTEXT_DOMAIN.pot"
git push
else
echo "Not enough changes to commit (only $CHANGED_LINES lines changed)"
fi
else
echo "No changes to commit"
fi