Invalid cron syntax in schedule ("Invalid workflow file") in CI
GitHub validates the schedule cron against POSIX cron syntax: exactly five fields (minute, hour, day-of-month, month, day-of-week). A missing field, an out-of-range value, or an unquoted * triggers an "Invalid workflow file" error.
What this error means
The workflow fails to load with "Invalid workflow file" and a message pointing at the cron value, or the schedule silently never runs because the expression is malformed.
Invalid workflow file: .github/workflows/nightly.yml
The workflow is not valid. .github/workflows/nightly.yml (Line: 4, Col: 15):
Invalid cron: '0 25 * *' (only 4 fields, hour 25 out of range)Common causes
Wrong number of fields
Cron needs five fields. 0 25 * * has four, and hour 25 is invalid; GitHub rejects it.
Unquoted expression breaks YAML
A leading * (like * 3 * * *) is a YAML alias character. The cron must be quoted, e.g. '0 3 * * *'.
How to fix it
Use five quoted fields in valid ranges
- Write minute (0-59), hour (0-23), day-of-month (1-31), month (1-12), day-of-week (0-6).
- Quote the whole expression so YAML does not misread
*. - Validate with a cron checker before committing.
on:
schedule:
- cron: '0 3 * * *' # 03:00 UTC dailyFix out-of-range values
Correct any field outside its allowed range; hours are 0-23, not 1-24.
# wrong: '0 24 * * *'
# right: '0 0 * * *' # midnight UTCHow to prevent it
- Always quote cron expressions in YAML.
- Keep to five fields and valid numeric ranges.
- Validate cron with a linter or crontab.guru before pushing.