Skip to content

Commit dac88a4

Browse files
author
Maciej Olko
committed
Add update of README to GitHub Action
1 parent 932559b commit dac88a4

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

.github/workflows/update.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches:
66
- '*'
77
jobs:
8-
update:
8+
update-translation:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v1
@@ -19,9 +19,27 @@ jobs:
1919
env:
2020
TX_TOKEN: ${{ secrets.TX_TOKEN }}
2121
- run: git config --local user.email 'maciej.olko@gmail.com'
22-
- run: git config --local user.name 'Maciej Olko'
22+
- run: git config --local user.name "GitHub Action's update-translation job"
2323
- run: git commit -a -m 'Update translation from Transifex' || true
2424
- uses: ad-m/github-push-action@master
2525
with:
2626
github_token: ${{ secrets.GITHUB_TOKEN }}
2727
branch: 3.8
28+
update-readme:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v1
32+
- uses: actions/setup-python@v1
33+
with:
34+
python-version: 3.8
35+
- run: pip install requests numpy
36+
- run: ./manage_translations.py recreate_readme
37+
env:
38+
TX_TOKEN: ${{ secrets.TX_TOKEN }}
39+
- run: git config --local user.email 'maciej.olko@gmail.com'
40+
- run: git config --local user.name "GitHub Action's update-readme job"
41+
- run: git commit -a -m 'Update translation progress' || true
42+
- uses: ad-m/github-push-action@master
43+
with:
44+
github_token: ${{ secrets.GITHUB_TOKEN }}
45+
branch: 3.8

manage_translations.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@ def _get_resources():
8282
from requests import get
8383
resources = []
8484
offset = 0
85-
with open('.tx/api-key') as f:
86-
transifex_api_key = f.read()
85+
if os.path.exists('.tx/api-key'):
86+
with open('.tx/api-key') as f:
87+
transifex_api_key = f.read()
88+
else:
89+
transifex_api_key = os.getenv('TX_TOKEN')
8790
while True:
8891
response = get(
8992
f'https://api.transifex.com/organizations/python-doc/projects/{PROJECT_SLUG}/resources/',

0 commit comments

Comments
 (0)