Undo accidental auth removal in check_artifact_exists action

This commit is contained in:
Reuben Morais 2021-07-28 14:24:11 +02:00
parent 4cd1a1cec4
commit 2020f1b15a
2 changed files with 7 additions and 0 deletions

View File

@ -37,6 +37,7 @@ async function getGoodArtifacts(client, owner, repo, releaseId, name) {
async function main() { async function main() {
try { try {
const token = core.getInput("github_token", { required: true });
const [owner, repo] = core.getInput("repo", { required: true }).split("/"); const [owner, repo] = core.getInput("repo", { required: true }).split("/");
const path = core.getInput("path", { required: true }); const path = core.getInput("path", { required: true });
const name = core.getInput("name"); const name = core.getInput("name");
@ -44,6 +45,7 @@ async function main() {
const releaseTag = core.getInput("release-tag"); const releaseTag = core.getInput("release-tag");
const OctokitWithThrottling = GitHub.plugin(throttling); const OctokitWithThrottling = GitHub.plugin(throttling);
const client = new OctokitWithThrottling({ const client = new OctokitWithThrottling({
auth: token,
throttle: { throttle: {
onRateLimit: (retryAfter, options) => { onRateLimit: (retryAfter, options) => {
console.log( console.log(
@ -54,6 +56,9 @@ async function main() {
if (options.request.retryCount <= 2) { if (options.request.retryCount <= 2) {
console.log(`Retrying after ${retryAfter} seconds!`); console.log(`Retrying after ${retryAfter} seconds!`);
return true; return true;
} else {
console.log("Exhausted 2 retries");
core.setFailed("Exhausted 2 retries");
} }
}, },
onAbuseLimit: (retryAfter, options) => { onAbuseLimit: (retryAfter, options) => {
@ -61,6 +66,7 @@ async function main() {
console.log( console.log(
`Abuse detected for request ${options.method} ${options.url}` `Abuse detected for request ${options.method} ${options.url}`
); );
core.setFailed(`GitHub REST API Abuse detected for request ${options.method} ${options.url}`)
}, },
}, },
}); });
@ -101,6 +107,7 @@ async function main() {
await Download(artifact.url, dir, { await Download(artifact.url, dir, {
headers: { headers: {
"Accept": "application/octet-stream", "Accept": "application/octet-stream",
"Authorization": `token ${token}`,
}, },
}); });
} }