Add CI status badge implementation to commit controller
This commit is contained in:
parent
01a406f5b0
commit
14f928b730
|
@ -57,6 +57,12 @@ class Projects::CommitController < Projects::ApplicationController
|
|||
render layout: false
|
||||
end
|
||||
|
||||
def status
|
||||
status_sha = ci_commit.sha if ci_commit
|
||||
image = Ci::ImageForBuildService.new.execute(@project, sha: status_sha)
|
||||
send_file(image.path, filename: image.name, disposition: 'inline', type: 'image/svg+xml')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def commit
|
||||
|
|
|
@ -493,6 +493,13 @@ Rails.application.routes.draw do
|
|||
constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ },
|
||||
as: :commits
|
||||
)
|
||||
|
||||
get(
|
||||
'/status/*id/badge',
|
||||
to: 'commit#status',
|
||||
constraints: { format: /png/ },
|
||||
as: :commit_status
|
||||
)
|
||||
end
|
||||
|
||||
resource :avatar, only: [:show, :destroy]
|
||||
|
|
Loading…
Reference in New Issue