mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-23 20:27:02 +08:00
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
This commit is contained in:
@@ -29,11 +29,29 @@ const getGitService = (): string => {
|
||||
return 'github';
|
||||
};
|
||||
|
||||
const isFork = (): boolean => {
|
||||
if (
|
||||
`${context.eventName}` !== 'pull_request' ||
|
||||
`${context.eventName}` !== 'pull_request_target'
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const baseLabel = context.payload.pull_request.base.label;
|
||||
const headLabel = context.payload.pull_request.head.label;
|
||||
|
||||
core.info(`baseRef: ${baseLabel} | headRef: ${headLabel}`);
|
||||
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'));
|
||||
|
||||
if (useOIDC) {
|
||||
if (!url) {
|
||||
url = 'https://codecov.io';
|
||||
|
||||
Reference in New Issue
Block a user