Conditional skip of a scheduled run by branch in CI
Since a schedule always runs on the default branch, a branch-based if like github.ref == 'refs/heads/develop' will never match under cron. Skip scheduled runs using the event name, the repository, or a job-level guard instead.
What this error means
A step guarded by a branch condition never runs under the schedule, or a scheduled run executes in a fork you did not intend it to run in.
.github/workflows/nightly.yml
# This never runs on schedule because the ref is the default branch:
- if: github.ref == 'refs/heads/develop'
run: ./nightly.shCommon causes
Branch conditions do not match under schedule
The schedule ref is the default branch, so any non-default branch condition evaluates false and skips the step.
No guard against running in forks
Without a repository check, a scheduled job can run in forks you did not intend.
How to fix it
Guard on event name and repository
- Use
github.event_name == 'schedule'to detect cron runs. - Add
github.repository == 'owner/repo'to skip forks. - Avoid non-default-branch conditions for scheduled steps.
.github/workflows/nightly.yml
- if: github.event_name == 'schedule' && github.repository == 'acme/app'
run: ./nightly.shSkip with a job-level condition
Gate the whole job so it only runs on the intended repository and event.
.github/workflows/nightly.yml
jobs:
nightly:
if: github.event_name == 'schedule'
runs-on: ubuntu-latestHow to prevent it
- Never use non-default-branch conditions for scheduled steps.
- Guard forks with a repository check.
- Prefer event-name conditions for cron-specific logic.
Related guides
Scheduled workflow not running (only runs on the default branch) in CIFix a GitHub Actions scheduled workflow that never runs - the schedule event only triggers when the workflow…
Scheduled workflow not running on a fork in CIUnderstand why a forked repository does not run scheduled GitHub Actions workflows - schedules are disabled o…
Cron for a specific weekday or day of month in CIWrite a GitHub Actions cron that runs on a specific weekday or day of month - understand how the day-of-month…