Skip to content

Commit 5a299d1

Browse files
fix: bypass token checks for forks and OIDC (#1404)
* chore(log): dump context * fix: add logic to bypass token for forks * fix: running the same things * fix: more logging * fix: more core info * fix: run the func * fix: cleanup
1 parent dad251d commit 5a299d1

File tree

3 files changed

+57
-25
lines changed

3 files changed

+57
-25
lines changed

dist/index.js

+37-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/buildExec.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,29 @@ const getGitService = (): string => {
2929
return 'github';
3030
};
3131

32+
const isFork = (): boolean => {
33+
if (
34+
`${context.eventName}` !== 'pull_request' ||
35+
`${context.eventName}` !== 'pull_request_target'
36+
) {
37+
return false;
38+
}
39+
40+
const baseLabel = context.payload.pull_request.base.label;
41+
const headLabel = context.payload.pull_request.head.label;
42+
43+
core.info(`baseRef: ${baseLabel} | headRef: ${headLabel}`);
44+
return (baseLabel.split(':')[0] !== headLabel.split(':')[0]);
45+
};
46+
3247
const getToken = async (): Promise<string> => {
48+
if (isFork()) {
49+
core.info('==> Fork detected, tokenless uploading used');
50+
return Promise.resolve('');
51+
}
3352
let token = core.getInput('token');
3453
let url = core.getInput('url');
3554
const useOIDC = isTrue(core.getInput('use_oidc'));
36-
3755
if (useOIDC) {
3856
if (!url) {
3957
url = 'https://codecov.io';

0 commit comments

Comments
 (0)