-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.rb
More file actions
44 lines (36 loc) · 1019 Bytes
/
application.rb
File metadata and controls
44 lines (36 loc) · 1019 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'sinatra'
require 'octokit'
require 'pry'
require 'json'
module Octokit
class Client
module Issues
def update_issue_milestone(repo, number, milestone)
patch "#{Repository.path repo}/issues/#{number}", {:milestone => milestone}
end
end
end
end
client = Octokit::Client.new(:access_token => ENV['GITHUB_TOKEN'])
get '/' do
"Awesome Github Labeler"
end
post '/' do
if params["payload"]
payload = JSON.parse(params["payload"])
if payload["action"] == "labeled"
issue = payload["issue"]["number"]
label = payload["label"]["name"]
if ["refactoring", "bug"].include? label
client.add_labels_to_an_issue("fairmondo/fairmondo",issue,["ready"])
client.update_issue_milestone("fairmondo/fairmondo",issue,15)
end
elsif payload["action"] == "opened"
issue = payload["issue"]["number"]
user = payload["issue"]["user"]["login"]
if user != "annakress"
client.update_issue_milestone("fairmondo/fairmondo",issue,15)
end
end
end
end