utils/github: avoid returning artifacts with the same name

This commit is contained in:
Ruoyu Zhong 2024-04-17 07:35:40 +08:00
parent 135db8c559
commit 9ad60fe437
No known key found for this signature in database

View File

@ -357,9 +357,11 @@ module GitHub
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