change page service deploy key

This commit is contained in:
呱呱呱 2023-08-21 09:50:01 +08:00
parent 13768a2f3a
commit 1b944e4914
1 changed files with 13 additions and 5 deletions

View File

@ -2,11 +2,18 @@ require 'net/http'
require 'uri'
class PageService
def self.get_deploykey()
@deploy_key = EduSetting.find_by_name("site_page_deploy_key").value
end
def self.genernate_user(user_id)
get_deploykey()
Rails.logger.info "################### PageService genernate_user #{user_id}"
user = User.find user_id
if user.id_card_verify == true && user.website_permission == true
uri = URI.parse("http://gitlink.kingchan.cn/gitlink_execute_script?key=#{Rails.application.config_for(:configuration)['deploy_key']}&script_path=create_dir&owner=#{user.login.downcase}")
uri = URI.parse("http://gitlink.kingchan.cn/gitlink_execute_script?key=#{@deploy_key}&script_path=create_dir&owner=#{user.login.downcase}")
response = Net::HTTP.get_response(uri)
end
Rails.logger.info "################### PageService genernate_user end #{response.body}"
@ -14,12 +21,13 @@ class PageService
end
def self.close_site(user_id,identifier=nil)
get_deploykey()
Rails.logger.info "################### PageService close_site #{user_id} / #{identifier}"
user = User.find user_id
uri = if identifier.present?
URI.parse("http://gitlink.kingchan.cn/gitlink_execute_script?key=#{Rails.application.config_for(:configuration)['deploy_key']}&script_path=remove_dir&owner=#{user.login.downcase}/#{identifier}/")
URI.parse("http://gitlink.kingchan.cn/gitlink_execute_script?key=#{@deploy_key}&script_path=remove_dir&owner=#{user.login.downcase}/#{identifier}/")
else
URI.parse("http://gitlink.kingchan.cn/gitlink_execute_script?key=#{Rails.application.config_for(:configuration)['deploy_key']}&script_path=remove_dir&owner=#{user.login.downcase}/")
URI.parse("http://gitlink.kingchan.cn/gitlink_execute_script?key=#{@deploy_key}&script_path=remove_dir&owner=#{user.login.downcase}/")
end
response = Net::HTTP.get_response(uri)
Rails.logger.info "################### PageService close_site end #{response.body}"
@ -27,6 +35,7 @@ class PageService
end
def self.deploy_page(branch, page_id)
get_deploykey()
Rails.logger.info "################### PageService deploy #{branch} for page #{page_id}"
page = Page.find page_id
user = page.user
@ -52,8 +61,7 @@ class PageService
end
if script_path.present?
deploy_key = EduSetting.find_by_name("site_page_deploy_key")
uri = URI.parse("http://gitlink.kingchan.cn/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.kingchan.cn/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)
Rails.logger.info "################### PageService deploy #{response.body}"
return response.body