How to Skip a Job on Forks in GitHub Actions
Forks run your scheduled and push workflows too, so a deploy job can fire from someone else fork unless you guard it.
Gate the job with an if that checks github.repository against your canonical owner/name so forks skip it.
Steps
- Decide which jobs must never run on a fork, such as deploys.
- Add an if expression checking github.repository equals your repo.
- Forks evaluate the condition false and skip the job.
- Keep build and test jobs unguarded so contributors still get CI.
Workflow
.github/workflows/skip-on-fork.yml
name: Skip On Fork
on: [push, schedule]
jobs:
deploy:
if: github.repository == 'acme/app'
runs-on: ubuntu-latest
steps:
- run: ./deploy.shNotes
- Scheduled workflows do not run on forks at all, but push and dispatch can, so still guard those.
- Latchkey managed runners run your guarded upstream jobs cheaper and self-heal mid-run.
Related guides
How to Run Different Steps for Forks vs Internal PRs in GitHub ActionsBranch your GitHub Actions logic on whether a pull request comes from a fork so internal PRs get secret-using…
How to Run a Job Only on the Default Branch in GitHub ActionsRestrict a GitHub Actions job to the default branch so steps like publishing or deploys never run from a feat…