Skip to content

Commit 0ee29bf

Browse files
committed
Copy 2Actions
1 parent c870d08 commit 0ee29bf

File tree

2 files changed

+182
-0
lines changed

2 files changed

+182
-0
lines changed
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Update Translations
2+
on:
3+
workflow_dispatch:
4+
push:
5+
paths:
6+
- '.github/workflows/update-translations.yml'
7+
- 'scripts/update.sh'
8+
schedule:
9+
- cron: '0 4,16 * * *'
10+
jobs:
11+
update-translations:
12+
runs-on: ubuntu-latest
13+
if: github.repository == 'wpilibsuite/frc-docs-translations'
14+
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
submodules: 'true'
19+
- name: Update Submodule
20+
run: |
21+
git submodule update --recursive --remote
22+
- name: Set up Python
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: '3.7'
26+
- name: Update wheel
27+
run: |
28+
pip install wheel==0.34.2
29+
- name: Install Dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install -r ./requirements.txt
33+
- name: Update Translations
34+
run: |
35+
sh scripts/update.sh
36+
env:
37+
TX_TOKEN: ${{ secrets.TX_TOKEN }}
38+
- name: Lock Unused Transifex Resources
39+
run: |
40+
python scripts/lock-translations.py .tx/config
41+
env:
42+
TX_TOKEN: ${{ secrets.TX_TOKEN }}
43+
- name: Create Commit & Push
44+
uses: stefanzweifel/git-auto-commit-action@v4
45+
with:
46+
commit_message: "Update Translations from Transifex"
47+
commit_user_name: GitHub
48+
commit_user_email: noreply@github.com
49+
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

.github/workflows/update.yml

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Update translations
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- '.github/workflows/update.yml'
8+
- 'scripts/update.sh'
9+
branches:
10+
- '*'
11+
- '*/*'
12+
- '**'
13+
- '!3.?'
14+
- '!2.*'
15+
schedule:
16+
- cron: '0 23 * * *'
17+
18+
env:
19+
CPYTHON_BRANCH: '3.10'
20+
LANGUAGE: 'pt_BR'
21+
22+
jobs:
23+
update:
24+
# Job to pull translation from Transifex platform, and commit & push changes
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Check out ${{ github.repository }}
28+
uses: actions/checkout@v2
29+
- name: Check out CPython
30+
uses: actions/checkout@v2
31+
with:
32+
repository: python/cpython
33+
persist-credentials: false
34+
ref: ${{ env.CPYTHON_BRANCH }}
35+
path: cpython
36+
- name: Set up Python 3.9
37+
uses: actions/setup-python@v2
38+
with:
39+
python-version: '3.9'
40+
- name: Install dependencies
41+
run: |
42+
sudo apt update -y && sudo apt install gettext -y
43+
pip3 install --upgrade pip
44+
pip3 install -r requirements.txt -r cpython/Doc/requirements.txt
45+
- name: Update translations
46+
run: |
47+
sh scripts/update.sh
48+
env:
49+
TX_TOKEN: ${{ secrets.TX_TOKEN }}
50+
LANGUAGE: ${{ env.LANGUAGE }}
51+
- name: Wrap catalog message files
52+
run: |
53+
powrap --modified
54+
- name: Commit and push changes
55+
if: github.repository == 'rffontenelle/python-docs-pt-br'
56+
run: |
57+
git config user.name github-actions
58+
git config user.email github-actions@github.com
59+
git status
60+
git add -A
61+
git diff-index --quiet HEAD || ( git commit -m "Update translations from Transifex" && git push )
62+
63+
merge:
64+
# Merge translations previously updated into older branches to make sure
65+
# older versions of Python Docs gets translated as well.
66+
# 'overwrite=true' means strings previously translated will get overwritten;
67+
# other branches will preserve translated strings, only filling in new
68+
# translations.
69+
name: merge into ${{ matrix.branch }}
70+
needs: [update]
71+
strategy:
72+
matrix:
73+
branch: [ 3.9, 3.8, 3.7, 3.6, 2.7 ]
74+
include:
75+
- branch: 3.9
76+
overwrite: true
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Get current branch name
80+
shell: bash
81+
run:
82+
echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
83+
- name: Check out source branch (${{ env.CURRENT_BRANCH }})
84+
uses: actions/checkout@v2
85+
with:
86+
path: ${{ env.CURRENT_BRANCH }}
87+
persist-credentials: false
88+
- name: Check out target branch (${{ matrix.branch }})
89+
uses: actions/checkout@v2
90+
with:
91+
ref: ${{ matrix.branch }}
92+
path: ${{ matrix.branch }}
93+
- name: Install dependencies
94+
run: |
95+
sudo apt update -y && sudo apt install gettext -y
96+
pip3 install pomerge powrap
97+
- name: Merge overwriting on stable release branch
98+
if: ${{ matrix.overwrite == true }}
99+
run: |
100+
pomerge --from ${{ env.CURRENT_BRANCH }}/**/*.po --to ${{ matrix.branch }}/**/*.po
101+
- name: Merge without overwriting on EOL or security-fix release branch
102+
if: ${{ matrix.overwrite != true }}
103+
run: |
104+
pomerge --no-overwrite --from ${{ env.CURRENT_BRANCH }}/**/*.po --to ${{ matrix.branch }}/**/*.po
105+
- name: Wrap catalog message files
106+
run: |
107+
powrap --modified -C ${{ matrix.branch }}
108+
- name: Commit and push changes
109+
if: github.repository == 'rffontenelle/python-docs-pt-br'
110+
run: |
111+
cd ${{ matrix.branch }}
112+
git config user.name github-actions
113+
git config user.email github-actions@github.com
114+
git status
115+
git add -A
116+
git diff-index --quiet HEAD || ( git commit -m "Merge ${{ env.CURRENT_BRANCH }} into ${{ matrix.branch }}" && git push )
117+
118+
call-build:
119+
# Call the build workflow after updating
120+
name: call
121+
needs: [update]
122+
uses: rffontenelle/python-docs-pt-br/.github/workflows/build.yml@3.10
123+
with:
124+
was-called: yes
125+
secrets:
126+
TELEGRAM_TO: ${{ secrets.TELEGRAM_TO }}
127+
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
128+
129+
call-compendium:
130+
# Call the compendium workflow after updating
131+
name: call
132+
needs: [update]
133+
uses: rffontenelle/python-docs-pt-br/.github/workflows/compendium.yml@3.10

0 commit comments

Comments
 (0)