build service change
This commit is contained in:
parent
71fd9969cb
commit
477b21e633
|
@ -36,7 +36,11 @@ class SitePagesController < ApplicationController
|
||||||
if data.nil?
|
if data.nil?
|
||||||
data = JSON.parse(response_str)["error"]
|
data = JSON.parse(response_str)["error"]
|
||||||
end
|
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") })
|
render_ok({data: data.nil? ? nil : data.split("\n") })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,7 +54,17 @@ class SitePagesController < ApplicationController
|
||||||
return normal_status(-1, "该仓库还未开通Page服务,无法进行部署") if Page.exists?(user: user, project: project)
|
return normal_status(-1, "该仓库还未开通Page服务,无法进行部署") if Page.exists?(user: user, project: project)
|
||||||
|
|
||||||
@page = Page.find_by(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
|
render_ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
# state_description :string(255)
|
# state_description :string(255)
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
|
# last_build_info :text(65535)
|
||||||
|
# build_state :boolean
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
@ -47,4 +49,8 @@ class Page < ApplicationRecord
|
||||||
"http://#{user.login}.#{@deploy_domain}/#{identifier}"
|
"http://#{user.login}.#{@deploy_domain}/#{identifier}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def build_script_path
|
||||||
|
"#{language_frame}_build"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,20 +47,7 @@ class PageService
|
||||||
repo_link = project.repository.url
|
repo_link = project.repository.url
|
||||||
repo = project.repository.identifier
|
repo = project.repository.identifier
|
||||||
branch = branch
|
branch = branch
|
||||||
script_path = nil
|
script_path =page.build_script_path
|
||||||
script_path = case page.language_frame
|
|
||||||
when "hugo"
|
|
||||||
"hugo_build"
|
|
||||||
|
|
||||||
when "jekyll"
|
|
||||||
"jekyll_build"
|
|
||||||
|
|
||||||
when "hexo"
|
|
||||||
"hexo_build"
|
|
||||||
else
|
|
||||||
"hugo_build"
|
|
||||||
end
|
|
||||||
|
|
||||||
if script_path.present?
|
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}")
|
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)
|
response = Net::HTTP.get_response(uri)
|
||||||
|
|
|
@ -9,6 +9,8 @@ json.theme page.theme
|
||||||
json.state page.state
|
json.state page.state
|
||||||
json.state_description page.state_description
|
json.state_description page.state_description
|
||||||
json.language_frame page.language_frame
|
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.url page.url
|
||||||
json.created_at page.created_at.strftime("%Y-%m-%d %H:%M:%S")
|
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")
|
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