How to detect a pull request from a fork

I have a project that uses cypress dashboard. To access this we use 20 runners (our max concurrency) and a secret token.

This uses

fail-fast: false

otherwise when one runner fails they will terminate without updating the cypress dashboard.
https://github.com/cypress-io/github-action/issues/48

When we recieve a PR from a fork it takes up all 20 of our available runners, but only uses 1 (because it does not have the secret token). This takes ~3 hours.

Is it possible to detect if the PR came from a fork so I can adjust the matrix size?

2 Likes

I found the following works (ensure you replace org/repo).

Fork:

if: ${{ github.event.pull_request.head.repo.full_name != 'org/repo' }}

Not a fork:

if: ${{ github.event.pull_request.head.repo.full_name == 'org/repo' }}
2 Likes

This also seems to work which is more generic, than actually naming the repo:

if: github.event.pull_request.head.repo.full_name == github.repository
2 Likes