Skip to content

Commit

Permalink
set max num times we can look for an old artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
vezenovm committed Dec 6, 2024
1 parent d88f752 commit 510d7da
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ function run() {
if (github_1.context.eventName === "pull_request") {
try {
core.startGroup(`Searching artifact "${baseReport}" on repository "${repository}", on branch "${baseBranch}"`);
let count = 100;
let artifactId = null;
try {
// Artifacts are returned in most recent first order.
Expand All @@ -448,7 +449,11 @@ function run() {
_e = false;
try {
const res = _c;
if (count == 0) {
break;
}
const artifact = res.data.find((artifact) => !artifact.expired && artifact.name === baseReport);
count = count - 1;
if (!artifact) {
yield new Promise((resolve) => setTimeout(resolve, 900)); // avoid reaching the API rate limit
continue;
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,21 @@ async function run() {
core.startGroup(
`Searching artifact "${baseReport}" on repository "${repository}", on branch "${baseBranch}"`
);

let count = 100;
let artifactId: number | null = null;
// Artifacts are returned in most recent first order.
for await (const res of octokit.paginate.iterator(octokit.rest.actions.listArtifactsForRepo, {
owner,
repo,
})) {
if (count == 0) {
break;
}
const artifact = res.data.find(
(artifact) => !artifact.expired && artifact.name === baseReport
);

count = count - 1;
if (!artifact) {
await new Promise((resolve) => setTimeout(resolve, 900)); // avoid reaching the API rate limit

Expand Down

0 comments on commit 510d7da

Please sign in to comment.