How to Trigger a Workflow When the Repository Is Forked in GitHub Actions
The fork event fires in the upstream repository whenever someone forks it, exposing the new fork in the payload.
Add on.fork (it has no activity types). Read github.event.forkee.full_name to know which fork was created and notify or onboard the contributor.
Steps
- Add
fork:underon. - Read
github.event.forkee.full_namefor the new fork. - Send a notification or start onboarding automation.
Workflow
.github/workflows/on-fork.yml
on:
fork:
jobs:
notify:
runs-on: ubuntu-latest
steps:
- run: echo "Repo forked to ${{ github.event.forkee.full_name }}"Gotchas
- The fork event has no
types:filter; it always fires on any fork. - It runs in the source repository, so it has access to that repository secrets.
Related guides
How to Safely Trigger on pull_request_target in GitHub ActionsUse the pull_request_target event to run trusted automation on fork PRs in GitHub Actions with write access,…
How to Trigger a Workflow on a Milestone Event in GitHub ActionsRun a GitHub Actions workflow when a milestone is created, closed, or edited using the milestone event, for r…