Multiple cron schedules in one workflow in CI
A workflow can list several cron entries under schedule, and each fires independently. If only one seems to run, check that every entry is valid and quoted; a single bad cron can make the whole schedule invalid.
What this error means
You defined two or three cron lines but only some fire, or the workflow fails to load because one of the cron entries is malformed.
on:
schedule:
- cron: '0 3 * * *' # daily
- cron: '0 12 * * 1' # Monday noon
# If a third entry is invalid, the whole file is rejected.Common causes
One invalid entry invalidates the schedule
Every cron under schedule must be valid; a single malformed one causes an "Invalid workflow file" error for the whole workflow.
No way to tell which cron fired
All entries run the same jobs, so without checking github.event.schedule you cannot branch per cron.
How to fix it
List valid crons and branch on the trigger
- Add each cron as its own list item under
schedule. - Validate all entries; keep them quoted.
- Use
github.event.scheduleto run different steps per cron.
on:
schedule:
- cron: '0 3 * * *'
- cron: '0 12 * * 1'
jobs:
run:
runs-on: ubuntu-latest
steps:
- if: github.event.schedule == '0 12 * * 1'
run: echo "weekly path"Split unrelated schedules into separate workflows
If the jobs differ a lot, use one workflow file per schedule so a broken cron does not disable the others.
How to prevent it
- Validate every cron entry before committing.
- Branch on
github.event.schedulewhen entries differ. - Split very different schedules into separate workflow files.