mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-16 09:45:57 +08:00
FIX 优化ci流程,并配置gitea相关database
This commit is contained in:
@@ -2,9 +2,9 @@ class Ci::ProjectsController < Ci::BaseController
|
||||
include RepositoriesHelper
|
||||
|
||||
before_action :load_project
|
||||
before_action :load_repo, only: [:update_trustie_pipeline]
|
||||
before_action :load_repo, only: [:update_trustie_pipeline, :activate, :deactivate]
|
||||
before_action :authorize_owner_project!, only: [:authorize]
|
||||
before_action :find_cloud_account, only: [:authorize]
|
||||
before_action :find_cloud_account, only: [:authorize, :activate, :deactivate]
|
||||
|
||||
def authorize
|
||||
@user = current_user
|
||||
@@ -33,4 +33,40 @@ class Ci::ProjectsController < Ci::BaseController
|
||||
end
|
||||
end
|
||||
|
||||
def activate
|
||||
return render_error('你还未认证') unless current_user.ci_certification?
|
||||
|
||||
begin
|
||||
ActiveRecord::Base.transaction do
|
||||
if @repo
|
||||
return render_error('该项目已经激活') if @repo.repo_active?
|
||||
if @project.ci_reactivate?
|
||||
@project.ci_reactivate!(@repo)
|
||||
return render_ok
|
||||
end
|
||||
@repo.activate!(@ci_user.user_id)
|
||||
else
|
||||
@repo = Ci::Repo.auto_create!(@ci_user, @project)
|
||||
@ci_user.update_column(:user_syncing, false)
|
||||
end
|
||||
|
||||
result = bind_hook!(current_user, @cloud_account, @repo)
|
||||
@project.update_columns(open_devops: true, gitea_webhook_id: result['id'])
|
||||
@project.increment!(:open_devops_count)
|
||||
@cloud_account.update_column(:ci_user_id, @ci_user.user_id)
|
||||
end
|
||||
render_ok
|
||||
rescue Exception => ex
|
||||
render_error(ex.message)
|
||||
end
|
||||
end
|
||||
|
||||
def deactivate
|
||||
return render_error('已经是激活状态') if @repo.repo_active?
|
||||
|
||||
@project.update_column(open_devops: false)
|
||||
@repo.deactivate!
|
||||
render_ok
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user