Fixing issues with the handling of the token and avoiding error on when the token is undefined

This commit is contained in:
Peter Murray 2023-11-17 12:11:45 +00:00 committed by GitHub
parent 78078da0cd
commit 86039b0e74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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