Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Set max number of times we search from an old artifact #9

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading