-
Notifications
You must be signed in to change notification settings - Fork 16
Description
I am observing an error running codechecks in Github Actions - Provider should never be in fork mode and not in PR mode!
It appears as if there is a false positive as the PR is not coming from a fork. The code is here:
monorepo/packages/client/src/getExecutionContext.ts
Lines 20 to 25 in 13986fe
| const isFork = await ciProvider.isFork(); | |
| const pr = await ciProvider.getPullRequestID(); | |
| const projectSlug = await ciProvider.getProjectSlug(); | |
| if (!pr && isFork) { | |
| throw new Error("Provider should never be in fork mode and not in PR mode!"); | |
| } |
For Github actions, !pr is always true
monorepo/packages/client/src/ci-providers/GithubActions.ts
Lines 14 to 16 in ba52ad8
| getPullRequestID(): number | undefined { | |
| return undefined; | |
| } |
And isFork is always true because GITHUB_HEAD_REF is set for PRs submitted from the same repo. See the docs here: https://docs.github.com/en/actions/reference/environment-variables
monorepo/packages/client/src/ci-providers/GithubActions.ts
Lines 27 to 31 in ba52ad8
| isFork(): boolean { | |
| // This is only set for forked repositories | |
| // @see https://help.github.com/en/articles/virtual-environments-for-github-actions#default-environment-variables | |
| return !!this.env["GITHUB_HEAD_REF"]; | |
| } |
GITHUB_HEAD_REF Only set for pull request events. The name of the head branch.
Perhaps there is a better way to determine there the PR is coming from a fork, will update if I determine a good solution