Add the auth token into the params for the API requests
This commit is contained in:
parent
24c907137c
commit
c7410e0c65
3 changed files with 14 additions and 4 deletions
|
|
@ -34,7 +34,12 @@ const release = await axios.get(
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await addReleaseAsset(release.data.upload_url, `wiki.zip`, `wiki.zip`);
|
await addReleaseAsset(
|
||||||
|
release.data.upload_url,
|
||||||
|
`wiki.zip`,
|
||||||
|
`wiki.zip`,
|
||||||
|
{ TOKEN },
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`Failed to add asset to the release`);
|
console.error(`Failed to add asset to the release`);
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,10 @@ const release = await axios.post(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const meta = { TOKEN };
|
||||||
try {
|
try {
|
||||||
await addReleaseAsset(release.data.upload_url, `release.zip`, `release.zip`);
|
await addReleaseAsset(release.data.upload_url, `release.zip`, `release.zip`, meta);
|
||||||
await addReleaseAsset(release.data.upload_url, MANIFEST_NAME, MANIFEST_FILE);
|
await addReleaseAsset(release.data.upload_url, MANIFEST_NAME, MANIFEST_FILE, meta);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`Failed to add assets to the release`);
|
console.error(`Failed to add assets to the release`);
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,11 @@ export function assertEnvKey(key, { checkTruthiness = true } = {}) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function addReleaseAsset(url, name, filepath) {
|
export async function addReleaseAsset(url, name, filepath, { TOKEN } = {}) {
|
||||||
|
if (!TOKEN) {
|
||||||
|
console.error(`Must provide addReleaseAsset an authentication token`);
|
||||||
|
throw new Error("Missing auth token");
|
||||||
|
};
|
||||||
const stream = createReadStream(filepath);
|
const stream = createReadStream(filepath);
|
||||||
return axios.post(
|
return axios.post(
|
||||||
url,
|
url,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue