Skip to content

Commit d6af016

Browse files
Update and pull python-docs-theme project (#187)
1 parent 023beb0 commit d6af016

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Update and pull python-docs-theme project
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
paths-ignore:
8+
- 'docs/**'
9+
- '.readthedocs.yaml'
10+
- 'sample-workflows/**'
11+
pull_request:
12+
branches:
13+
- 'main'
14+
paths-ignore:
15+
- 'docs/**'
16+
- '.readthedocs.yaml'
17+
- 'sample-workflows/**'
18+
workflow_dispatch:
19+
inputs:
20+
push:
21+
description: "Push source strings and translations to Transifex"
22+
type: boolean
23+
pull:
24+
description: "Pull translations from Transifex"
25+
type: boolean
26+
schedule:
27+
- cron: '0 0 * * 1'
28+
29+
env:
30+
TX_CLI_VERSION: '1.6.16'
31+
32+
jobs:
33+
update:
34+
runs-on: ubuntu-latest
35+
permissions:
36+
contents: write
37+
38+
steps:
39+
- name: Check out repository
40+
uses: actions/[email protected]
41+
with:
42+
ref: python-docs-theme
43+
44+
- name: Check out python-docs-theme
45+
uses: actions/[email protected]
46+
with:
47+
repository: python/python-docs-theme
48+
persist-credentials: false
49+
path: python-docs-theme
50+
51+
- name: Set up Python 3
52+
uses: actions/[email protected]
53+
with:
54+
python-version: 3
55+
cache: 'pip'
56+
cache-dependency-path: |
57+
python-docs-theme/requirements.txt
58+
59+
- name: Install Transifex CLI
60+
working-directory: /usr/local/bin
61+
run: |
62+
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash -s -- v${{ env.TX_CLI_VERSION }}
63+
64+
- name: Install dependencies
65+
run: |
66+
sudo apt update -y && sudo apt install gettext -y
67+
pip3 install --upgrade pip
68+
pip3 install -r python-docs-theme/requirements.txt
69+
70+
- name: Generate and store POT file
71+
run: |
72+
python python-docs-theme/babel_runner.py extract
73+
cp python-docs-theme/python_docs_theme/locale/python-docs-theme.pot .
74+
75+
- name: Push source strings to Transifex
76+
if: ${{ github.event_name == 'schedule' ||
77+
(github.event_name == 'workflow_dispatch' && github.event.inputs.push == 'true') }}
78+
id: tx_push
79+
run: |
80+
tx push --source --skip
81+
env:
82+
TX_TOKEN: ${{ secrets.TX_TOKEN }}
83+
84+
- name: Pull translations for all languages
85+
if: ${{ github.event_name == 'schedule' ||
86+
(github.event_name == 'workflow_dispatch' && github.event.inputs.pull == 'true') }}
87+
run: |
88+
tx pull --all --translations --force
89+
env:
90+
TX_TOKEN: ${{ secrets.TX_TOKEN }}
91+
92+
- name: Commit changes
93+
run: |
94+
git config user.name github-actions[bot]
95+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
96+
git status
97+
98+
git ls-files --others --exclude-standard -- python-docs-theme.pot | xargs -r git add -v
99+
git ls-files --others --exclude-standard -- ./*/LC_MESSAGES/python-docs-theme.po | xargs -r git add -v
100+
git diff -I'^"POT-Creation-Date: ' --numstat ./*/LC_MESSAGES/python-docs-theme.po python-docs-theme.pot | cut -f3 | xargs -r git add -v
101+
git diff-index --cached --quiet HEAD || { git commit -vm "Update translations from Transifex"; }
102+
103+
- name: Push changes
104+
if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
105+
run: |
106+
git push

0 commit comments

Comments
 (0)