-
-
Notifications
You must be signed in to change notification settings - Fork 16
79 lines (76 loc) · 2.9 KB
/
main.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: update-translations
on:
workflow_dispatch:
pull_request:
schedule:
- cron: "0 0 * * *" #runs at 00:00 UTC everyday
jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write # for git push; turn all other permissions 'read'
env:
SPHINXINTL_TRANSIFEX_ORGANIZATION_NAME: sphinx-doc
SPHINXINTL_TRANSIFEX_PROJECT_NAME: sphinx-doc
TX_TOKEN: ${{ secrets.TX_TOKEN }}
steps:
# 1. Set up environment
- uses: actions/checkout@v4
- name: Initialize and update submodule
run: |
git submodule update --init --remote
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3
cache: 'pip'
- name: Set up git config
run: |
git config --global user.email "sphinx-auto-update"
git config --global user.name "sphinx-auto-update"
- name: Install graphviz
run: sudo apt-get install graphviz
- name: Install dependencies
run: |
pip install -U pip setuptools
pip install -r ./requirements.txt
- name: Install Transifex CLI
working-directory: /usr/local/bin
run: |
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
tx --version
# 2. Remove obsolete POT files from repository and obsolete resources from Transifex
- name: Generate templates from scratch
run: |
rm -rf ./locale/pot
./locale/generate_templates.sh
- name: Just print what would be locked and deleted of the resources in Transifex
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'sphinx-doc/sphinx-doc-translations' }}
run: locale/lock-translations.py locale/.tx/config -d
- name: Lock and delete obsolete resources in Transifex
if: github.event_name != 'pull_request'
run: locale/lock-translations.py locale/.tx/config
- name: Include obsolete catalog templates (pot files) for removal
run: |
deleted_files=$(git status -s | grep ^' D' | cut -d' ' -f3)
if [ -n "$deleted_files" ]; then git rm $deleted_files; fi
git checkout locale/
# 3. Update translation files
- name: Update translations
run: |
sh ./locale/generate_templates.sh
cat ./locale/.tx/config
sh ./locale/update.sh
- name: Include obsolete catalog messages (po files) for removal
run: |
deleted_files=$(git status -s | grep ^' D' | cut -d' ' -f3)
if [ -n "$deleted_files" ]; then git rm $deleted_files; fi
# 4. Commit and push changes
- name: After success
run: |
git add locale
git add sphinx
git diff-index --cached --quiet HEAD || git commit -vm "Update translations by GHA https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
- name: GitHub Push
if: github.event_name != 'pull_request'
run: git push