-
-
Notifications
You must be signed in to change notification settings - Fork 40
123 lines (100 loc) · 3.66 KB
/
sync.yml
File metadata and controls
123 lines (100 loc) · 3.66 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Sync
on:
workflow_call:
inputs:
version:
description: "Branch name corresponding to a Python version"
required: true
type: string
tx_project:
description: "Name of the Transifex translation project"
required: true
type: string
secrets:
TX_TOKEN:
description: "Token required for interacting with Transifex API"
required: false
env:
PYDOC_LANGUAGE: pt_BR
PYDOC_TX_PROJECT: ${{ inputs.tx_project }}
PYDOC_VERSION: ${{ inputs.version }}
TX_CLI_VERSION: '1.6.17'
jobs:
sync:
runs-on: ubuntu-latest
steps:
# 1- Set up environment
- name: Check out this repository
uses: actions/checkout@v6
- name: Set language dir variable
run:
echo "PYDOC_LANG_DIR=${{ env.PYDOC_VERSION }}" >> $GITHUB_ENV
- name: Checkout this repository ${{ env.PYDOC_VERSION }}
uses: actions/checkout@v6
with:
ref: ${{ env.PYDOC_VERSION }}
path: ${{ env.PYDOC_LANG_DIR }}
- uses: actions/setup-python@v6
with:
python-version: ${{ inputs.version }}
allow-prereleases: true
cache: 'pip'
pip-install: -r requirements.txt
# 2- Install dependencies
- name: Install Transifex CLI tool
run: |
cd /usr/local/bin
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash -s -- v$TX_CLI_VERSION
- name: Install APT dependencies
run: sudo apt update -y && sudo apt install gettext -y
# 3- Pull translations
- name: Generate updated .tx/config
if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
run: python scripts/generate_txconfig.py -p ./${{ env.PYDOC_LANG_DIR }} ${{ env.PYDOC_TX_PROJECT }}
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
- name: Pull translations from Transifex
id: pull
if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
run: |
# Clean up obsolete files
find ./${{ env.PYDOC_LANG_DIR }} -name '*.po' -exec rm {} \;
./scripts/pull_translations.sh
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
- name: Merge translations from newer branch
if: inputs.tx_project != 'python-newest' # python-newest doesn't have a newer branch
run: |
newer_branch=${PYDOC_VERSION%%.*}.$((${PYDOC_VERSION##*.}+1))
git clone --depth 1 --single-branch --branch $newer_branch https://github.com/python/python-docs-pt-br ${newer_branch}-dir
pomerge --from ./${newer_branch}-dir/{**/,}*.po --to ./${{ env.PYDOC_LANG_DIR }}/{**/,}*.po
rm -rf ./${newer_branch}-dir
- name: powrap
if: steps.pull.outcome == 'success'
run: |
cd ./${{ env.PYDOC_LANG_DIR }}
powrap *.po **/*.po
- name: Update statistics
if: always()
run: |
./scripts/stats.py
git -C ./${{ env.PYDOC_LANG_DIR }} diff stats.json
env:
PYDOC_LANG_DIR: ${{ env.PYDOC_LANG_DIR }}
- name: Update potodo.md
if: always()
run: |
./scripts/potodo.sh
git -C ./${{ env.PYDOC_LANG_DIR }} diff potodo.md
env:
PYDOC_LANG_DIR: ${{ env.PYDOC_LANG_DIR }}
# 4- Commit and push translations
- name: Commit
run: ./scripts/commit.sh
env:
PYDOC_LANG_DIR: ${{ env.PYDOC_LANG_DIR }}
- name: Push
if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
run: |
cd ./${{ env.PYDOC_LANG_DIR }}
git push