How do you prevent a workflow from running on forks of your repository (for example, scheduled jobs)?
BeginnerConceptTriggers & Events
Answer
Forks copy workflows, and scheduled or push workflows may run in the fork owner's account. Guard jobs with the repository name:
jobs:
nightly:
if: github.repository == 'devopsshack/shack-api'
Forks of public repos have Actions disabled until the owner enables them, but the guard keeps forks that enable Actions from attempting deploys that will fail anyway.
More on Triggers & Events
How do you trigger a workflow on pushes to `main` and on PRs that target `main`?BeginnerWhat activity types does `pull_request` trigger on by default, and how do you add more?IntermediateHow do `branches` and `branches-ignore` filters work with globs?BeginnerHow do path filters work, and what are their limits?AdvancedHow do you trigger only on version tags, and what is the gotcha with pushing many tags?IntermediateWhat is `workflow_dispatch`, and what input types does it support?Beginner