Skip to content

Update Languages

Update Languages #114

Workflow file for this run

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 }}