-
Notifications
You must be signed in to change notification settings - Fork 362
58 lines (52 loc) · 1.78 KB
/
update_langs.yml
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
name: Update Languages
on:
schedule:
# At 01:00 AM, on Monday
- cron: 0 1 * * 1
workflow_dispatch:
env:
CURR_LANG_FILE_PATH: ${{github.workspace}}/gtts/langs.py
TEMP_LANG_FILE_PATH: ${{github.workspace}}/scripts/langs_temp.py
jobs:
gen_langs:
runs-on: ubuntu-latest
name: Create PR
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install gTTS
run: |
python -m pip install --upgrade pip
pip install .
- name: Run gen_langs.py
# Generate languages from the source
run: python scripts/gen_langs.py ${TEMP_LANG_FILE_PATH}
- name: Run check_langs.py
# Compare generated languages with current ones
id: check_langs
run: python scripts/check_langs.py
# Only do the rest (update/create pr) if a commit is needed
- name: Update langs.py
# Replace gtts langs.py with langs_temps
if: ${{ fromJSON(steps.check_langs.outputs.must_commit) }}
run: cp "${TEMP_LANG_FILE_PATH}" "${CURR_LANG_FILE_PATH}"
# Create new branch/PR with any changes
- name: Create PR
if: ${{ fromJSON(steps.check_langs.outputs.must_commit) }}
uses: peter-evans/create-pull-request@v7
with:
add-paths: ${{ env.CURR_LANG_FILE_PATH }}
commit-message: ${{ env.LANGS_COMMIT_MESSAGE }} # from check_langs
delete-branch: true
base: main
title: Language Updates
body: |
This PR was created automatically because languages changes were detected upstream:
> ${{ env.LANGS_COMMIT_MESSAGE }}