-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathserver.rb
More file actions
27 lines (20 loc) · 724 Bytes
/
server.rb
File metadata and controls
27 lines (20 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true
require 'sinatra'
require 'net/http'
require 'json'
require_relative './github_to_cctray.rb'
get '/' do
# redirect to example project
redirect '/build-canaries/nevergreen/nevergreen.yml'
end
get '/:group/:repo/:workflow' do |group, repo, workflow|
content_type 'application/xml'
uri = URI("https://api.github.com/repos/#{group}/#{repo}/actions/workflows/#{workflow}/runs")
req = Net::HTTP::Get.new(uri)
req['Authorization'] = "token #{params[:token]}" if params[:token]
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
response = http.request(req)
payload = JSON.parse(response.read_body)
GithubToCCTray.new.convert_to_xml(payload, params[:branch])
end