更改:webhook优化
This commit is contained in:
parent
ff57561aad
commit
08a5028006
|
@ -29,7 +29,8 @@ class Api::V1::Projects::SyncRepositoriesController < Api::V1::BaseController
|
||||||
else
|
else
|
||||||
@sync_repositories = SyncRepository.where(project: @project, sync_direction: params[:sync_direction])
|
@sync_repositories = SyncRepository.where(project: @project, sync_direction: params[:sync_direction])
|
||||||
end
|
end
|
||||||
@sync_repository_branches = SyncRepositoryBranch.where(sync_repository_id: @sync_repositories, enable: true)
|
branch = params[:ref].split("refs/heads/")[-1]
|
||||||
|
@sync_repository_branches = SyncRepositoryBranch.where(sync_repository_id: @sync_repositories, gitlink_branch_name: branch, enable: true)
|
||||||
# 全部分支同步暂时不做
|
# 全部分支同步暂时不做
|
||||||
# @sync_repositories.each do |item|
|
# @sync_repositories.each do |item|
|
||||||
# TouchSyncJob.perform_later(item)
|
# TouchSyncJob.perform_later(item)
|
||||||
|
|
|
@ -73,11 +73,17 @@ class Api::V1::Projects::SyncRepositories::CreateService < ApplicationService
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_webhook
|
def create_webhook
|
||||||
|
url = ""
|
||||||
|
if type == "SyncRepositories::Gitee"
|
||||||
|
url = "#{Rails.application.config_for(:configuration)['platform_url']}/api/v1/#{project&.owner&.login}/#{project&.identifier}/sync_repositories/sync?sync_direction=1&repo_type=SyncRepositories::Gitee"
|
||||||
|
else
|
||||||
|
url = "#{Rails.application.config_for(:configuration)['platform_url']}/api/v1/#{project&.owner&.login}/#{project&.identifier}/sync_repositories/sync?sync_direction=1&repo_type=SyncRepositories::Github"
|
||||||
|
end
|
||||||
webhook_params = {
|
webhook_params = {
|
||||||
active: true,
|
active: true,
|
||||||
branch_filter: '*',
|
branch_filter: '*',
|
||||||
http_method: 'POST',
|
http_method: 'POST',
|
||||||
url: "#{Rails.application.config_for(:configuration)['platform_url']}/api/v1/#{project&.owner&.login}/#{project&.identifier}/sync_repositories/sync?sync_direction=1",
|
url: url,
|
||||||
content_type: 'json',
|
content_type: 'json',
|
||||||
type: 'reposync',
|
type: 'reposync',
|
||||||
events: ["push"]
|
events: ["push"]
|
||||||
|
|
Loading…
Reference in New Issue