HTTP errors when the token is undefined (#556)

* 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>
This commit is contained in:
Peter Murray 2023-12-01 13:55:03 +00:00 committed by GitHub
parent a2374547df
commit 16ef37f8dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View File

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

4
dist/setup/index.js vendored
View File

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

View File

@ -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;
}