Merge pull request #14564 from cho-m/github-api-last-run

utils/github: get artifact from last run
This commit is contained in:
Mike McQuaid 2023-02-09 12:39:40 +00:00 committed by GitHub
commit e6548a89a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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