build service change
This commit is contained in:
parent
71fd9969cb
commit
477b21e633
|
@ -36,7 +36,11 @@ class SitePagesController < ApplicationController
|
|||
if data.nil?
|
||||
data = JSON.parse(response_str)["error"]
|
||||
end
|
||||
@page.update(last_build_at: Time.now)
|
||||
if data.include?("部署成功")
|
||||
@page.update(last_build_at: Time.now, build_state: true, last_build_info: data)
|
||||
else
|
||||
@page.update(build_state:false, last_build_info: data)
|
||||
end
|
||||
render_ok({data: data.nil? ? nil : data.split("\n") })
|
||||
end
|
||||
|
||||
|
@ -50,7 +54,17 @@ class SitePagesController < ApplicationController
|
|||
return normal_status(-1, "该仓库还未开通Page服务,无法进行部署") if Page.exists?(user: user, project: project)
|
||||
|
||||
@page = Page.find_by(user: user, project: project)
|
||||
@page.deploy_page(branch)
|
||||
response_str = @page.deploy_page(branch)
|
||||
data = JSON.parse(response_str)["result"]
|
||||
if data.nil?
|
||||
data = JSON.parse(response_str)["error"]
|
||||
end
|
||||
|
||||
if data.include?("部署成功")
|
||||
@page.update(last_build_at: Time.now, build_state: true, last_build_info: data)
|
||||
else
|
||||
@page.update(build_state:false, last_build_info: data)
|
||||
end
|
||||
render_ok
|
||||
end
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
# state_description :string(255)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# last_build_info :text(65535)
|
||||
# build_state :boolean
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
@ -47,4 +49,8 @@ class Page < ApplicationRecord
|
|||
"http://#{user.login}.#{@deploy_domain}/#{identifier}"
|
||||
end
|
||||
|
||||
def build_script_path
|
||||
"#{language_frame}_build"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -47,20 +47,7 @@ class PageService
|
|||
repo_link = project.repository.url
|
||||
repo = project.repository.identifier
|
||||
branch = branch
|
||||
script_path = nil
|
||||
script_path = case page.language_frame
|
||||
when "hugo"
|
||||
"hugo_build"
|
||||
|
||||
when "jekyll"
|
||||
"jekyll_build"
|
||||
|
||||
when "hexo"
|
||||
"hexo_build"
|
||||
else
|
||||
"hugo_build"
|
||||
end
|
||||
|
||||
script_path =page.build_script_path
|
||||
if script_path.present?
|
||||
uri = URI.parse("http://gitlink.#{@deploy_domain}/gitlink_execute_script?key=#{@deploy_key}&script_path=#{script_path}&project_dir=#{project_dir}&repo=#{repo}&repo_link=#{repo_link}&branch=#{branch}&owner=#{owner}")
|
||||
response = Net::HTTP.get_response(uri)
|
||||
|
|
|
@ -9,6 +9,8 @@ json.theme page.theme
|
|||
json.state page.state
|
||||
json.state_description page.state_description
|
||||
json.language_frame page.language_frame
|
||||
json.build_state page.build_state
|
||||
json.last_build_info page.last_build_info.to_s.split("\n")
|
||||
json.url page.url
|
||||
json.created_at page.created_at.strftime("%Y-%m-%d %H:%M:%S")
|
||||
json.last_build_at page.last_build_at.nil? ? nil : page.last_build_at.strftime("%Y-%m-%d %H:%M:%S")
|
|
@ -0,0 +1,6 @@
|
|||
class AddLastBuildInfoAndStateToPages < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :pages, :last_build_info, :text
|
||||
add_column :pages, :build_state, :boolean
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue