Skip to content
Latchkey

Update Languages workflow (pndurette/gTTS)

The Update Languages workflow from pndurette/gTTS, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get caching, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: pndurette/gTTS.github/workflows/update_langs.ymlLicense MITView source

What it does

This is the Update Languages workflow from the pndurette/gTTS repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
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 }}

The same workflow, on Latchkey

Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.

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:
    timeout-minutes: 30
    runs-on: latchkey-small
    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:
          cache: 'pip'
          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 }}

What changed

1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow