Skip to content
Latchkey

How to Schedule a Retraining Pipeline in GitHub Actions

A cron-scheduled workflow pulls fresh data, retrains, checks an evaluation gate, and publishes the model only when the gate passes.

Use on.schedule with a cron expression to trigger retraining, chain data pull to train to evaluate with needs:, and gate the publish step on an accuracy threshold so a worse model is never released.

Steps

  • Trigger with on.schedule (UTC cron) plus workflow_dispatch.
  • Chain pull, train, and evaluate jobs with needs:.
  • Publish only when the eval gate passes.

Workflow

.github/workflows/retrain.yml
on:
  schedule:
    - cron: '0 4 * * 1'   # 04:00 UTC every Monday
  workflow_dispatch:
jobs:
  retrain:
    runs-on: [self-hosted, gpu]
    steps:
      - uses: actions/checkout@v4
      - run: dvc pull -j 4
      - run: python train.py --epochs 3
      - name: Eval gate
        run: python evaluate.py --min-accuracy 0.90
      - name: Publish if gate passed
        run: python publish.py
        env:
          HF_TOKEN: ${{ secrets.HF_TOKEN }}

Gotchas

  • Scheduled runs use the default branch and can be delayed under platform load.
  • Fail the eval gate before publish so a regression never ships automatically.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →