Skip to content

Add Pagination Support for Runs with >30 Artifacts#90

Merged
dawidd6 merged 1 commit into
dawidd6:masterfrom
streem:master
Jul 13, 2021
Merged

Add Pagination Support for Runs with >30 Artifacts#90
dawidd6 merged 1 commit into
dawidd6:masterfrom
streem:master

Conversation

@nickthegroot

Copy link
Copy Markdown
Contributor

Currently, runs with over 30 artifacts only download the first 30 published. This PR adds support to page through all artifacts and download them accordingly.

@dawidd6

dawidd6 commented Jul 13, 2021

Copy link
Copy Markdown
Owner

Could you please make use of:

for await (const artifacts of client.paginate.iterator(...

You can see it earlier in this file as an example.

@nickthegroot

Copy link
Copy Markdown
Contributor Author

Could you please make use of:

for await (const artifacts of client.paginate.iterator(...

You can see it earlier in this file as an example.

Ah - I didn't know Octokit came with a built-in paginator! The default client.paginate seems to do what we're looking for without needing to loop through anything.

Comment thread main.js
console.log("==> RunID:", runID)

let artifacts = await client.actions.listWorkflowRunArtifacts({
let artifacts = await client.paginate(client.actions.listWorkflowRunArtifacts, {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to do this in a loop. See how it is done above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dawidd6 We could do it in a loop, but it would just be the same as what's going on with the default paginate. The above loop is different since we bail out early once the correct run has been found (vs here, where we would never bail since we always want all artifacts).

@dawidd6 dawidd6 Jul 13, 2021

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just read the docs. Didn't know about it.

@dawidd6 dawidd6 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@dawidd6 dawidd6 merged commit 63b63ee into dawidd6:master Jul 13, 2021
sscott1-godaddy added a commit to gdcorp-action-public-forks/action-download-artifact that referenced this pull request Sep 16, 2021
* Add pagination when listing all artifacts (dawidd6#90)

Co-authored-by: Nick DeGroot <1966472+nickthegroot@users.noreply.github.com>

* main: remove ';'

* README: fix

* main: throw if no runID

* action: only success

* README: update

* workflows: test empty conclusion

* Fix octokit returning weird results from listWorkflowRuns (dawidd6#95)

Closes: dawidd6#93 

Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>

* README: remove stray dot

* download aritfact from latest run which upload an artifact (dawidd6#88)

Co-authored-by: Nick DeGroot <nbdegroot1@gmail.com>
Co-authored-by: Nick DeGroot <1966472+nickthegroot@users.noreply.github.com>
Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>
Co-authored-by: Dirk <dirks@seatfrog.com>
Co-authored-by: Tailong <54169577+shitlsh@users.noreply.github.com>
Ma-ve pushed a commit to Ma-ve/action-download-artifact-with-retry that referenced this pull request Jun 24, 2025
Co-authored-by: Nick DeGroot <1966472+nickthegroot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants