How to Avoid the Scheduled-Runs-Run-on-Default-Branch-Only Gotcha in GitHub Actions
A schedule trigger reads the workflow file from the default branch only, so edits on a feature branch never take effect until merged.
GitHub evaluates on.schedule using the version of the workflow on the default branch. To validate a schedule change before merge, add a temporary workflow_dispatch and run it from your branch.
Steps
- Accept that schedule changes take effect only after merging to the default branch.
- Add
workflow_dispatchso you can trigger the same jobs from any branch for testing. - After confirming, remove or keep the manual trigger and merge.
Workflow
.github/workflows/ci.yml
on:
schedule:
- cron: '0 3 * * *'
workflow_dispatch: # lets you test from a feature branch before merge
jobs:
nightly:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./nightly.shGotchas
- A brand-new scheduled workflow does nothing until it exists on the default branch.
- Schedules also disable themselves after 60 days of repository inactivity.
Related guides
How to Combine a Schedule With Manual Dispatch in GitHub ActionsLet one GitHub Actions workflow run both on a cron schedule and on demand by listing schedule and workflow_di…
How to Run a Workflow on a Cron Schedule in GitHub ActionsTrigger a GitHub Actions workflow on a recurring timetable with on.schedule and a five-field POSIX cron expre…