mirror of
https://github.com/codecov/codecov-action.git
synced 2026-02-13 14:37:24 +00:00
fix: don't overwrite overrideBranch & add comments decribing getToken
This commit is contained in:
parent
775cafb3b3
commit
d7991a51f0
3 changed files with 17 additions and 5 deletions
10
dist/index.js
vendored
10
dist/index.js
vendored
|
|
@ -32350,12 +32350,18 @@ const isPullRequestFromFork = () => {
|
||||||
core.info(`baseRef: ${baseLabel} | headRef: ${headLabel}`);
|
core.info(`baseRef: ${baseLabel} | headRef: ${headLabel}`);
|
||||||
return (baseLabel.split(':')[0] !== headLabel.split(':')[0]);
|
return (baseLabel.split(':')[0] !== headLabel.split(':')[0]);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Returning null in getToken means that we're using tokenless.
|
||||||
|
* Returning an empty string from getToken means that the token was not set
|
||||||
|
and we don't seem to be uploading from a fork so we are not using tokenless
|
||||||
|
*/
|
||||||
const getToken = () => buildExec_awaiter(void 0, void 0, void 0, function* () {
|
const getToken = () => buildExec_awaiter(void 0, void 0, void 0, function* () {
|
||||||
let token = core.getInput('token');
|
let token = core.getInput('token');
|
||||||
if (!token && isPullRequestFromFork()) {
|
if (!token && isPullRequestFromFork()) {
|
||||||
core.info('==> Fork detected, tokenless uploading used');
|
core.info('==> Fork detected, tokenless uploading used');
|
||||||
|
// backwards compatibility with certain versions of the CLI that expect this
|
||||||
process.env['TOKENLESS'] = context.payload.pull_request.head.label;
|
process.env['TOKENLESS'] = context.payload.pull_request.head.label;
|
||||||
return null;
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
let url = core.getInput('url');
|
let url = core.getInput('url');
|
||||||
const useOIDC = isTrue(core.getInput('use_oidc'));
|
const useOIDC = isTrue(core.getInput('use_oidc'));
|
||||||
|
|
@ -32382,7 +32388,7 @@ const buildCommitExec = () => buildExec_awaiter(void 0, void 0, void 0, function
|
||||||
const overridePr = core.getInput('override_pr');
|
const overridePr = core.getInput('override_pr');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = yield getToken();
|
const token = yield getToken();
|
||||||
if (token == null) {
|
if (!overrideBranch && token == null) {
|
||||||
overrideBranch = (_a = context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.head.label;
|
overrideBranch = (_a = context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.head.label;
|
||||||
}
|
}
|
||||||
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||||
|
|
|
||||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -45,12 +45,18 @@ const isPullRequestFromFork = (): boolean => {
|
||||||
return (baseLabel.split(':')[0] !== headLabel.split(':')[0]);
|
return (baseLabel.split(':')[0] !== headLabel.split(':')[0]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returning null in getToken means that we're using tokenless.
|
||||||
|
* Returning an empty string from getToken means that the token was not set
|
||||||
|
and we don't seem to be uploading from a fork so we are not using tokenless
|
||||||
|
*/
|
||||||
const getToken = async (): Promise<string | null> => {
|
const getToken = async (): Promise<string | null> => {
|
||||||
let token = core.getInput('token');
|
let token = core.getInput('token');
|
||||||
if (!token && isPullRequestFromFork()) {
|
if (!token && isPullRequestFromFork()) {
|
||||||
core.info('==> Fork detected, tokenless uploading used');
|
core.info('==> Fork detected, tokenless uploading used');
|
||||||
|
// backwards compatibility with certain versions of the CLI that expect this
|
||||||
process.env['TOKENLESS'] = context.payload.pull_request.head.label;
|
process.env['TOKENLESS'] = context.payload.pull_request.head.label;
|
||||||
return null;
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
let url = core.getInput('url');
|
let url = core.getInput('url');
|
||||||
const useOIDC = isTrue(core.getInput('use_oidc'));
|
const useOIDC = isTrue(core.getInput('use_oidc'));
|
||||||
|
|
@ -83,7 +89,7 @@ const buildCommitExec = async (): Promise<{
|
||||||
const overridePr = core.getInput('override_pr');
|
const overridePr = core.getInput('override_pr');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = await getToken();
|
const token = await getToken();
|
||||||
if (token == null) {
|
if (!overrideBranch && token == null) {
|
||||||
overrideBranch = context.payload.pull_request?.head.label;
|
overrideBranch = context.payload.pull_request?.head.label;
|
||||||
}
|
}
|
||||||
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue