pass token explicitly

This commit is contained in:
softprops 2021-08-07 23:57:32 -04:00
parent 085ff2701b
commit ea51250dd0
3 changed files with 22 additions and 1936 deletions

1939
dist/index.js vendored

File diff suppressed because it is too large Load diff

View file

@ -128,7 +128,7 @@ export const mimeOrDefault = (path: string): string => {
};
export const upload = async (
gh: GitHub,
ghToken: string,
url: string,
path: string
): Promise<any> => {
@ -141,7 +141,7 @@ export const upload = async (
headers: {
"content-length": `${size}`,
"content-type": mime,
authorization: `${gh.auth}`
authorization: `token ${ghToken}`
},
method: "POST",
body
@ -150,6 +150,11 @@ export const upload = async (
console.log(resp.status);
const json = await resp.json();
console.log(`body`, json);
if (resp.status !== 201) {
throw new Error(
"failed to upload release asset ${name}. recieved status code ${resp.status}\n${json}"
);
}
return json;
// return await gh.rest.repos.uploadReleaseAsset({

View file

@ -32,10 +32,10 @@ async function run() {
}
}
const oktokit = GitHub.plugin(
require("@octokit/plugin-throttling"),
require("@octokit/plugin-retry")
);
// const oktokit = GitHub.plugin(
// require("@octokit/plugin-throttling"),
// require("@octokit/plugin-retry")
// );
const gh = getOctokit(config.github_token, {
//new oktokit(
@ -67,7 +67,7 @@ async function run() {
}
await Promise.all(
files.map(async path => {
await upload(gh, uploadUrl(rel.upload_url), path);
await upload(config.github_token, uploadUrl(rel.upload_url), path);
})
).catch(error => {
throw error;