Skip to content

Commit

Permalink
fix: add logic to bypass token for forks
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrockhu-codecov committed Apr 30, 2024
1 parent ae7230e commit 4960f3d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
9 changes: 9 additions & 0 deletions dist/index.js
Expand Up @@ -32562,7 +32562,16 @@ const getGitService = () => {
}
return 'github';
};
const isFork = () => {
const baseLabel = context.payload.pull_request.base.label;
const headLabel = context.payload.pull_request.head.label;
return (baseLabel.split(':')[0] !== headLabel.split(':')[0]);
};
const getToken = () => buildExec_awaiter(void 0, void 0, void 0, function* () {
if (isFork) {
core.info('==> Fork detected, tokenless uploading used');
return Promise.resolve('');
}
let token = core.getInput('token');
let url = core.getInput('url');
const useOIDC = isTrue(core.getInput('use_oidc'));
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions src/buildExec.ts
Expand Up @@ -29,7 +29,19 @@ const getGitService = (): string => {
return 'github';
};

const isFork = (): boolean => {
const baseLabel = context.payload.pull_request.base.label;
const headLabel = context.payload.pull_request.head.label;

return (baseLabel.split(':')[0] !== headLabel.split(':')[0]);
};

const getToken = async (): Promise<string> => {
if (isFork) {
core.info('==> Fork detected, tokenless uploading used');
return Promise.resolve('');
}

let token = core.getInput('token');
let url = core.getInput('url');
const useOIDC = isTrue(core.getInput('use_oidc'));
Expand Down

0 comments on commit 4960f3d

Please sign in to comment.