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 ( export const upload = async (
gh: GitHub, ghToken: string,
url: string, url: string,
path: string path: string
): Promise<any> => { ): Promise<any> => {
@ -141,7 +141,7 @@ export const upload = async (
headers: { headers: {
"content-length": `${size}`, "content-length": `${size}`,
"content-type": mime, "content-type": mime,
authorization: `${gh.auth}` authorization: `token ${ghToken}`
}, },
method: "POST", method: "POST",
body body
@ -150,6 +150,11 @@ export const upload = async (
console.log(resp.status); console.log(resp.status);
const json = await resp.json(); const json = await resp.json();
console.log(`body`, 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 json;
// return await gh.rest.repos.uploadReleaseAsset({ // return await gh.rest.repos.uploadReleaseAsset({

View file

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