update-index workflow (rasa/scoop-directory)
The update-index workflow from rasa/scoop-directory, explained and optimized by Latchkey.
CI health: B - good
Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the update-index workflow from the rasa/scoop-directory 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
# https://canovasjm.netlify.app/2020/11/29/github-actions-run-a-python-script-on-schedule-and-commit-changes/
name: update-index
on:
workflow_dispatch:
schedule:
# run at 15:00 UTC every day (8am PDT/UTC-7)
- cron: '0 15 * * *'
jobs:
update-index:
runs-on: ubuntu-latest
steps:
- name: run actions/checkout@v4
uses: actions/checkout@v4
# fails: https://github.com/rasa/scoop-directory/runs/4252997621?check_suite_focus=true#step:7:8
# - name: run actions/cache@v2 - pip
# uses: actions/cache@v2
# id: pip
# with:
# path: ~/.cache/pip
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
# restore-keys: |
# ${{ runner.os }}-pip-
# causes errors, see
# https://github.com/rasa/scoop-directory/runs/4265697748?check_suite_focus=true#step:6:1097
# - name: run actions/cache@v2 - cache
# uses: actions/cache@v2
# id: cache
# with:
# path: cache
# key: ${{ runner.os }}-cache-${{ hashFiles('**/cache.pickle') }}
# restore-keys: |
# ${{ runner.os }}-cache-
- name: run actions/setup-python@v5
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip' # caching pip dependencies
- name: run pip install -r maintenance/requirements.txt
# if: steps.pip.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: run python maintenance/github-crawler.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python maintenance/github-crawler.py
- name: run git commit -am "update index [ci skip]"
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add -A
git commit -am "update index [ci skip]"
- name: run ad-m/github-push-action@v0.8.0
uses: ad-m/github-push-action@v0.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
# https://canovasjm.netlify.app/2020/11/29/github-actions-run-a-python-script-on-schedule-and-commit-changes/ name: update-index on: workflow_dispatch: schedule: # run at 15:00 UTC every day (8am PDT/UTC-7) - cron: '0 15 * * *' jobs: update-index: timeout-minutes: 30 runs-on: latchkey-small steps: - name: run actions/checkout@v4 uses: actions/checkout@v4 # fails: https://github.com/rasa/scoop-directory/runs/4252997621?check_suite_focus=true#step:7:8 # - name: run actions/cache@v2 - pip # uses: actions/cache@v2 # id: pip # with: # path: ~/.cache/pip # key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} # restore-keys: | # ${{ runner.os }}-pip- # causes errors, see # https://github.com/rasa/scoop-directory/runs/4265697748?check_suite_focus=true#step:6:1097 # - name: run actions/cache@v2 - cache # uses: actions/cache@v2 # id: cache # with: # path: cache # key: ${{ runner.os }}-cache-${{ hashFiles('**/cache.pickle') }} # restore-keys: | # ${{ runner.os }}-cache- - name: run actions/setup-python@v5 uses: actions/setup-python@v5 with: python-version: '3.12' cache: 'pip' # caching pip dependencies - name: run pip install -r maintenance/requirements.txt # if: steps.pip.outputs.cache-hit != 'true' run: | python -m pip install --upgrade pip pip install -r requirements.txt - name: run python maintenance/github-crawler.py env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: python maintenance/github-crawler.py - name: run git commit -am "update index [ci skip]" run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git add -A git commit -am "update index [ci skip]" - name: run ad-m/github-push-action@v0.8.0 uses: ad-m/github-push-action@v0.8.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: master
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Add a job timeout so a hung step cannot burn hours of runner time.
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:
- Dependency installs
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.