|
# Adapted from python/python-docs-pt-br |
|
# Original (replaced update.yml): https://github.com/python/python-docs-pt-br/blob/main/.github/workflows/sync.yml |
|
name: Update translations |
|
|
|
on: |
|
workflow_dispatch: |
|
schedule: |
|
- cron: '40 23 * * *' |
|
|
|
permissions: |
|
contents: read |
|
|
|
env: |
|
CPYTHON_BRANCH: '3.15' |
|
LANGUAGE: 'ja' |
|
TX_CLI_VERSION: '1.6.17' |
|
|
|
jobs: |
|
update: |
|
# Job to pull translation from Transifex platform, and commit & push changes |
|
runs-on: ubuntu-latest |
|
permissions: |
|
contents: write |
|
steps: |
|
- name: Check out ${{ github.repository }} |
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
|
with: |
|
ref: ${{ env.CPYTHON_BRANCH }} |
|
- name: Check out CPython |
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
|
with: |
|
repository: python/cpython |
|
persist-credentials: false |
|
ref: ${{ env.CPYTHON_BRANCH }} |
|
path: cpython |
|
- name: Set up Python |
|
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 |
|
with: |
|
python-version: ${{ env.CPYTHON_BRANCH }} |
|
allow-prereleases: true |
|
cache: 'pip' |
|
cache-dependency-path: '**/requirements*.txt' |
|
- name: Install Transifex CLI |
|
run: | |
|
curl -fsSL https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash -s -- "v${TX_CLI_VERSION}" |
|
working-directory: /usr/local/bin |
|
- name: Install dependencies |
|
run: | |
|
sudo apt-get update -y && sudo apt-get install gettext -y |
|
pip install --upgrade pip |
|
pip install -r requirements.txt -r cpython/Doc/requirements.txt |
|
- name: Update translations |
|
run: | |
|
sh scripts/update.sh |
|
env: |
|
TX_TOKEN: ${{ secrets.TX_TOKEN }} |
|
LANGUAGE: ${{ env.LANGUAGE }} |
|
- name: Wrap catalog message files |
|
run: | |
|
powrap --modified |
|
- name: Commit and push changes |
|
if: github.repository == 'python/python-docs-ja' |
|
run: | |
|
git config user.name github-actions |
|
git config user.email github-actions@github.com |
|
git status |
|
git add -A |
|
git diff-index --quiet HEAD || ( git commit -m "Update translations from Transifex" && git push ) |
|
|
|
merge: |
|
# Merge translations previously updated into older branches to make sure |
|
# older versions of Python Docs gets translated as well. |
|
name: merge into ${{ matrix.branch }} |
|
needs: [update] |
|
strategy: |
|
matrix: |
|
branch: [ "3.14", "3.13" ] |
|
|
|
runs-on: ubuntu-latest |
|
permissions: |
|
contents: write |
|
steps: |
|
- name: Check out source branch (${{ env.CPYTHON_BRANCH }}) |
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
|
with: |
|
ref: ${{ env.CPYTHON_BRANCH }} |
|
path: ${{ env.CPYTHON_BRANCH }} |
|
persist-credentials: false |
|
|
|
- name: Check out target branch (${{ matrix.branch }}) |
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
|
with: |
|
ref: ${{ matrix.branch }} |
|
path: ${{ matrix.branch }} |
|
|
|
- name: Set up Python |
|
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 |
|
with: |
|
python-version: ${{ env.CPYTHON_BRANCH }} |
|
allow-prereleases: true |
|
cache: 'pip' |
|
cache-dependency-path: '**/requirements*.txt' |
|
|
|
- name: Install dependencies |
|
run: | |
|
sudo apt-get update -y && sudo apt-get install gettext -y |
|
pip install pomerge powrap |
|
|
|
- name: Merge overwriting on stable release branch |
|
run: | |
|
python "${{ env.CPYTHON_BRANCH }}/scripts/translations.py" merge "${{ env.CPYTHON_BRANCH }}" "${{ matrix.branch }}" |
|
|
|
- name: Wrap catalog message files |
|
run: | |
|
powrap --modified -C "${{ matrix.branch }}" |
|
|
|
- name: Commit and push changes |
|
if: github.repository == 'python/python-docs-ja' |
|
run: | |
|
cd "${{ matrix.branch }}" |
|
git config user.name github-actions |
|
git config user.email github-actions@github.com |
|
git status |
|
git add -A |
|
git diff-index --quiet HEAD || ( git commit -m "Merge ${{ env.CPYTHON_BRANCH }} into ${{ matrix.branch }}" && git push ) |