class Object
Constants
- OWNER
- REPO
- WORKFLOW
Public Instance Methods
Source
# File script/download_system_indexes, line 47 def download_artifact(run_id, artifact_name, output_path) # First, get the artifact list uri = URI("https://api.github.com/repos/#{OWNER}/#{REPO}/actions/runs/#{run_id}/artifacts") req = Net::HTTP::Get.new(uri) req["Accept"] = "application/vnd.github+json" response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(req) end data = JSON.parse(response.body) artifact = data["artifacts"].find { |a| a["name"] == artifact_name } return nil unless artifact # Download the artifact (it's a zip file) download_url = artifact["archive_download_url"] uri = URI(download_url) req = Net::HTTP::Get.new(uri) req["Accept"] = "application/vnd.github+json" req["Authorization"] = "Bearer #{ENV['GITHUB_TOKEN']}" if ENV["GITHUB_TOKEN"] response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(req) end if response.code == "302" # Follow redirect redirect_uri = URI(response["Location"]) req = Net::HTTP::Get.new(redirect_uri) response = Net::HTTP.start(redirect_uri.hostname, redirect_uri.port, use_ssl: true) do |http| http.request(req) end end FileUtils.mkdir_p(File.dirname(output_path)) File.write(output_path, response.body) true end
Download artifact
Source
# File script/download_system_indexes, line 88 def extract_font_families(system_index_path) return Set.new unless File.exist?(system_index_path) index_data = YAML.load_file(system_index_path) font_families = Set.new index_data.each do |entry| family = entry["preferred_family_name"] || entry["family_name"] font_families.add(family) if family end font_families end
Extract font families from system index
Source
# File script/download_system_indexes, line 33 def get_jobs(run_id) uri = URI("https://api.github.com/repos/#{OWNER}/#{REPO}/actions/runs/#{run_id}/jobs") req = Net::HTTP::Get.new(uri) req["Accept"] = "application/vnd.github+json" response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(req) end data = JSON.parse(response.body) data["jobs"] end
Get jobs for a run
Source
# File script/download_system_indexes, line 16 def get_latest_run uri = URI("https://api.github.com/repos/#{OWNER}/#{REPO}/actions/workflows/#{WORKFLOW}/runs?per_page=1") req = Net::HTTP::Get.new(uri) req["Accept"] = "application/vnd.github+json" response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(req) end data = JSON.parse(response.body) run = data["workflow_runs"].first return nil unless run run["id"] end
Get the latest workflow run
Source
# File script/download_system_indexes, line 103 def map_os_to_platform(os_name) case os_name when /macos|macOS/ "macos" when /windows|Windows/ "windows" when /ubuntu|linux/ "linux" else "unknown" end end
Map OS name to platform name