fix: add logic to bypass token for forks

This commit is contained in:
Tom Hu 2024-04-30 17:21:50 +08:00
parent ae7230e0f1
commit 4960f3d5e8
No known key found for this signature in database
GPG key ID: 79155678363963D2
3 changed files with 22 additions and 1 deletions

9
dist/index.js vendored
View file

@ -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'));

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -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'));