diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index d2cde79847..f7cf045793 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -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 } diff --git a/Library/Homebrew/utils/github/api.rb b/Library/Homebrew/utils/github/api.rb index f783fbab93..225b5617f3 100644 --- a/Library/Homebrew/utils/github/api.rb +++ b/Library/Homebrew/utils/github/api.rb @@ -284,11 +284,11 @@ module GitHub end end - def self.paginate_rest(url, additional_query_params: nil, per_page: 100) + def self.paginate_rest(url, additional_query_params: nil, per_page: 100, scopes: [].freeze) (1..API_MAX_PAGES).each do |page| retry_count = 1 result = begin - API.open_rest("#{url}?per_page=#{per_page}&page=#{page}&#{additional_query_params}") + API.open_rest("#{url}?per_page=#{per_page}&page=#{page}&#{additional_query_params}", scopes:) rescue Error if retry_count < PAGINATE_RETRY_COUNT retry_count += 1