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
|
# File 'app/controllers/hooks_controller.rb', line 3
def github
event = {}
if params[:ref]
event[:name] = 'git:push'
if params[:ref].split('/')[1] == 'heads'
event[:branch] = params[:ref].split('refs/heads/')[-1]
end
event[:commit] = params[:after]
event[:project_id] = Project.find_by(repo_id: params[:repository][:id], repo_provider: 'github').try(:id)
elsif params[:pull_request]
event[:name] = 'git:pull_request'
event[:commit] = params[:pull_request][:head][:sha]
event[:branch] = params[:pull_request][:head][:ref]
event[:project_id] = Project.find_by(repo_id: params[:pull_request][:head][:repo][:id], repo_provider: 'github').try(:id)
event[:pull_request] = true
end
evt = Event.new(event)
evt.execute
render plain: 'OK'
end
|