Skip to content
Latchkey

How to Disable a Scheduled Workflow on Forks in GitHub Actions

Guard the scheduled job with an if that checks github.repository so forks never run your cron.

Forks inherit workflow files, so a scheduled job would fire in every fork. Add a job-level if comparing github.repository to the upstream slug to run it only there.

Steps

  • Add a job-level if: github.repository == 'owner/repo'.
  • Keep push and pull_request jobs unconditional so forks still get CI.
  • Optionally check github.event_name == 'schedule' to scope the guard.

Workflow

.github/workflows/ci.yml
on:
  schedule:
    - cron: '0 6 * * *'
jobs:
  nightly:
    if: github.repository == 'acme/widgets'
    runs-on: ubuntu-latest
    steps:
      - run: ./nightly.sh

Gotchas

  • Fork owners can disable Actions entirely, but the if guard is more reliable.
  • Hardcode the exact owner/repo; a rename requires updating the condition.

Related guides

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