From 16ef37f8dd292a31055a9ee0d26fa0a4efab58de Mon Sep 17 00:00:00 2001 From: Peter Murray <681306+peter-murray@users.noreply.github.com> Date: Fri, 1 Dec 2023 13:55:03 +0000 Subject: [PATCH] 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 --- dist/cleanup/index.js | 4 +++- dist/setup/index.js | 4 +++- src/util.ts | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index b3232022..971673a5 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -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; diff --git a/dist/setup/index.js b/dist/setup/index.js index 6f23cdb6..916f488b 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -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; diff --git a/src/util.ts b/src/util.ts index 8fac6931..94be2347 100644 --- a/src/util.ts +++ b/src/util.ts @@ -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; }