Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Actions isFork False Positive #80

Open
tynes opened this issue May 5, 2021 · 1 comment
Open

Github Actions isFork False Positive #80

tynes opened this issue May 5, 2021 · 1 comment

Comments

@tynes
Copy link

tynes commented May 5, 2021

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:

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

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

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

@krzkaczor
Copy link
Member

It should be fixed in: #81

beta released as: @codechecks/client@0.1.10-beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants