Skip to content

Commit c5815d0

Browse files
authored
Merge pull request python-docs-translations#3 from m-aciek/update
Automate the update, add generation time info
2 parents e796ca5 + 15d0004 commit c5815d0

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

.github/workflows/update.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
on:
2+
schedule:
3+
- cron: '*/30 * * * *'
4+
push:
5+
branches:
6+
- '*'
7+
workflow_dispatch:
8+
jobs:
9+
update:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- uses: actions/setup-python@main
15+
- uses: astral-sh/setup-uv@main
16+
- uses: actions/checkout@main
17+
- run: uv run generate.py
18+
- run: git config --local user.email [email protected]
19+
- run: git config --local user.name "GitHub Action's update job"
20+
- run: git add .
21+
- run: git commit -m 'Update progress values'
22+
- uses: ad-m/github-push-action@master
23+
with:
24+
github_token: ${{ secrets.GITHUB_TOKEN }}
25+
branch: ${{ github.ref }}

generate.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# "jinja2",
66
# ]
77
# ///
8+
from datetime import datetime, timezone
89
from pathlib import Path
910
from shutil import rmtree
1011
from tempfile import TemporaryDirectory
@@ -13,14 +14,15 @@
1314
from jinja2 import Template
1415

1516
completion_progress = []
17+
generation_time = datetime.now(timezone.utc)
1618

1719
with TemporaryDirectory() as tmpdir:
1820
for language in ('es', 'fr', 'id', 'it', 'ja', 'ko', 'pl', 'pt-br', 'tr', 'uk', 'zh-cn', 'zh-tw'):
1921
clone_path = Path(tmpdir, language)
2022
for branch in ('3.13', '3.12', '3.11', '3.10', '3.9'):
2123
try:
22-
Repo.clone_from(f'git@github.com:python/python-docs-{language}.git', clone_path, depth=1, branch=branch)
23-
except GitCommandError as e:
24+
Repo.clone_from(f'https://github.com/python/python-docs-{language}.git', clone_path, depth=1, branch=branch)
25+
except GitCommandError:
2426
print(f'failed to clone {language} {branch}')
2527
continue
2628
try:
@@ -58,11 +60,12 @@
5860
{% endfor %}
5961
</tbody>
6062
</table>
63+
<p>Last updated at {{ generation_time.strftime('%x %X %Z') }}.</p>
6164
</body>
6265
</html>
6366
""")
6467

65-
output = template.render(completion_progress=completion_progress)
68+
output = template.render(completion_progress=completion_progress, generation_time=generation_time)
6669

6770
with open("index.html", "w") as file:
6871
file.write(output)

index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h1>Python Docs Translation Dashboard</h1>
2424
<td data-label="language">es</td>
2525
<td data-label="branch">3.12</td>
2626
<td data-label="completion">
27-
<div class="progress-bar" style="width: 91.12%;">91.12%</div>
27+
<div class="progress-bar" style="width: 91.69%;">91.69%</div>
2828
</td>
2929
</tr>
3030

@@ -40,23 +40,23 @@ <h1>Python Docs Translation Dashboard</h1>
4040
<td data-label="language">uk</td>
4141
<td data-label="branch">3.12</td>
4242
<td data-label="completion">
43-
<div class="progress-bar" style="width: 68.76%;">68.76%</div>
43+
<div class="progress-bar" style="width: 68.32%;">68.32%</div>
4444
</td>
4545
</tr>
4646

4747
<tr>
4848
<td data-label="language">ja</td>
4949
<td data-label="branch">3.11</td>
5050
<td data-label="completion">
51-
<div class="progress-bar" style="width: 68.08%;">68.08%</div>
51+
<div class="progress-bar" style="width: 68.11%;">68.11%</div>
5252
</td>
5353
</tr>
5454

5555
<tr>
5656
<td data-label="language">pt-br</td>
5757
<td data-label="branch">3.13</td>
5858
<td data-label="completion">
59-
<div class="progress-bar" style="width: 62.71%;">62.71%</div>
59+
<div class="progress-bar" style="width: 62.82%;">62.82%</div>
6060
</td>
6161
</tr>
6262

@@ -110,5 +110,6 @@ <h1>Python Docs Translation Dashboard</h1>
110110

111111
</tbody>
112112
</table>
113+
<p>Last updated at 11/19/24 08:59:14 UTC.</p>
113114
</body>
114115
</html>

0 commit comments

Comments
 (0)