utils/github: paginate artifact API result
There can be too many artifacts in a workflow run to fit in a single API response, so we need to paginate the result.
This commit is contained in:
parent
f4f8a12509
commit
84abc628aa
@ -355,10 +355,17 @@ module GitHub
|
||||
end
|
||||
|
||||
run_id = check_suite.last["workflowRun"]["databaseId"]
|
||||
artifacts = API.open_rest("#{API_URL}/repos/#{user}/#{repo}/actions/runs/#{run_id}/artifacts", scopes:)
|
||||
artifacts = []
|
||||
per_page = 50
|
||||
API.paginate_rest("#{API_URL}/repos/#{user}/#{repo}/actions/runs/#{run_id}/artifacts",
|
||||
per_page:, scopes:) do |result|
|
||||
result = result["artifacts"]
|
||||
artifacts.concat(result)
|
||||
break if result.length < per_page
|
||||
end
|
||||
|
||||
matching_artifacts =
|
||||
artifacts["artifacts"]
|
||||
artifacts
|
||||
.group_by { |art| art["name"] }
|
||||
.select { |name| File.fnmatch?(artifact_pattern, name, File::FNM_EXTGLOB) }
|
||||
.map { |_, arts| arts.last }
|
||||
|
Loading…
x
Reference in New Issue
Block a user