Skip to content

Commit

Permalink
HTTP errors when the token is undefined (#556)
Browse files Browse the repository at this point in the history
* Fixing issues with the handling of the token and avoiding error on when the token is undefined

* chore: rebuild action

---------

Co-authored-by: Ivan Zosimov <ivanzosimov@github.com>
  • Loading branch information
peter-murray and Ivan Zosimov authored Dec 1, 2023
1 parent a237454 commit 16ef37f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion dist/cleanup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87931,9 +87931,11 @@ function getGitHubHttpHeaders() {
const token = core.getInput('token');
const auth = !token ? undefined : `token ${token}`;
const headers = {
authorization: auth,
accept: 'application/vnd.github.VERSION.raw'
};
if (auth) {
headers.authorization = auth;
}
return headers;
}
exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
Expand Down
4 changes: 3 additions & 1 deletion dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125282,9 +125282,11 @@ function getGitHubHttpHeaders() {
const token = core.getInput('token');
const auth = !token ? undefined : `token ${token}`;
const headers = {
authorization: auth,
accept: 'application/vnd.github.VERSION.raw'
};
if (auth) {
headers.authorization = auth;
}
return headers;
}
exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
Expand Down
6 changes: 5 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,13 @@ export function convertVersionToSemver(version: number[] | string) {
export function getGitHubHttpHeaders(): OutgoingHttpHeaders {
const token = core.getInput('token');
const auth = !token ? undefined : `token ${token}`;

const headers: OutgoingHttpHeaders = {
authorization: auth,
accept: 'application/vnd.github.VERSION.raw'
};

if (auth) {
headers.authorization = auth;
}
return headers;
}

0 comments on commit 16ef37f

Please sign in to comment.