utils/github: get artifact from last run

This commit is contained in:
Michael Cho 2023-02-08 18:22:58 -08:00
parent b0a74e5323
commit 3beca4f691
No known key found for this signature in database
GPG Key ID: F0487049DAE15338

View File

@ -337,15 +337,15 @@ module GitHub
EOS EOS
end end
status = check_suite.first["status"].sub("_", " ").downcase status = check_suite.last["status"].sub("_", " ").downcase
if status != "completed" if status != "completed"
raise API::Error, <<~EOS raise API::Error, <<~EOS
The newest workflow run for ##{pr} is still #{status}! The newest workflow run for ##{pr} is still #{status}!
#{Formatter.url check_suite.first["workflowRun"]["url"]} #{Formatter.url check_suite.last["workflowRun"]["url"]}
EOS EOS
end end
run_id = check_suite.first["workflowRun"]["databaseId"] run_id = check_suite.last["workflowRun"]["databaseId"]
artifacts = API.open_rest("#{API_URL}/repos/#{user}/#{repo}/actions/runs/#{run_id}/artifacts", scopes: scopes) artifacts = API.open_rest("#{API_URL}/repos/#{user}/#{repo}/actions/runs/#{run_id}/artifacts", scopes: scopes)
artifact = artifacts["artifacts"].select do |art| artifact = artifacts["artifacts"].select do |art|
@ -355,7 +355,7 @@ module GitHub
if artifact.empty? if artifact.empty?
raise API::Error, <<~EOS raise API::Error, <<~EOS
No artifact with the name `#{artifact_name}` was found! No artifact with the name `#{artifact_name}` was found!
#{Formatter.url check_suite.first["workflowRun"]["url"]} #{Formatter.url check_suite.last["workflowRun"]["url"]}
EOS EOS
end end