Skip to content

Commit

Permalink
fix: don't overwrite overrideBranch & add comments decribing getToken
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-sentry committed Aug 1, 2024
1 parent 775cafb commit d7991a5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
10 changes: 8 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32350,12 +32350,18 @@ const isPullRequestFromFork = () => {
core.info(`baseRef: ${baseLabel} | headRef: ${headLabel}`);
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* () {
let token = core.getInput('token');
if (!token && isPullRequestFromFork()) {
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;
return null;
return Promise.resolve(null);
}
let url = core.getInput('url');
const useOIDC = isTrue(core.getInput('use_oidc'));
Expand All @@ -32382,7 +32388,7 @@ const buildCommitExec = () => buildExec_awaiter(void 0, void 0, void 0, function
const overridePr = core.getInput('override_pr');
const slug = core.getInput('slug');
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;
}
const failCi = isTrue(core.getInput('fail_ci_if_error'));
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions src/buildExec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,18 @@ const isPullRequestFromFork = (): boolean => {
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> => {
let token = core.getInput('token');
if (!token && isPullRequestFromFork()) {
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;
return null;
return Promise.resolve(null);
}
let url = core.getInput('url');
const useOIDC = isTrue(core.getInput('use_oidc'));
Expand Down Expand Up @@ -83,7 +89,7 @@ const buildCommitExec = async (): Promise<{
const overridePr = core.getInput('override_pr');
const slug = core.getInput('slug');
const token = await getToken();
if (token == null) {
if (!overrideBranch && token == null) {
overrideBranch = context.payload.pull_request?.head.label;
}
const failCi = isTrue(core.getInput('fail_ci_if_error'));
Expand Down

0 comments on commit d7991a5

Please sign in to comment.