I’m trying to figure out how to prevent a step from running on a PR workflow if the PR is coming from a fork.
The workflow has a few steps that should always run, like building a docker image. The last step will read repo secrets to publish the docker image to a private repo, but I don’t want that step to attempt to run if the PR came from a fork.
The workflow already prevents the fork-triggered-PR from accessing the secrets, and thus gets a failed step, but it would be great if the PR didn’t get a red X on it, and instead just skipped that step.
I tried most of the available GITHUB_ environment variables, and none of them seem to provide a way to detect if the source of the PR is a fork.
The docs here state:
|GITHUB_HEAD_REF||Only set for forked repositories. The branch of the head repository.|
Only set for forked repositories. The branch of the base repository.
But this is not true. These are getting set for workflows running on any PR, whether they came from a fork or not.
GITHUB_REPOSITORY also seemed promising, but it ALWAYS displays the base repository, and never the fork repository.
Is there any way that I can have a step be skipped if the PR originated from a fork?