Skip to content

Commit

Permalink
utils/github: avoid returning artifacts with the same name
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongRuoyu committed Apr 16, 2024
1 parent 135db8c commit 9ad60fe
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Library/Homebrew/utils/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,11 @@ def self.get_artifact_urls(workflow_array)
run_id = check_suite.last["workflowRun"]["databaseId"]
artifacts = API.open_rest("#{API_URL}/repos/#{user}/#{repo}/actions/runs/#{run_id}/artifacts", scopes:)

matching_artifacts = artifacts["artifacts"].select do |art|
File.fnmatch?(artifact_pattern, art["name"], File::FNM_EXTGLOB)
end
matching_artifacts =
artifacts["artifacts"]
.group_by { |art| art["name"] }
.select { |name| File.fnmatch?(artifact_pattern, name, File::FNM_EXTGLOB) }
.map { |_, arts| arts.last }

if matching_artifacts.empty?
raise API::Error, <<~EOS
Expand Down

0 comments on commit 9ad60fe

Please sign in to comment.