forked from Trustie/forgeplus
fixed 仓库中已有流水线文件不读取加入到列表
This commit is contained in:
parent
7b1f50dc76
commit
3b13bc6c13
|
|
@ -11,22 +11,22 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
|
|||
db_files = pipelines.pluck(:file_name)
|
||||
@run_result = []
|
||||
@files.map { |i| i['name'] }.each do |file|
|
||||
unless db_files.include?(".gitea/workflows/#{file}")
|
||||
pipeline = Action::Pipeline.find_or_initialize_by(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""),
|
||||
file_name: ".gitea/workflows/#{file}",
|
||||
branch: @project.default_branch,
|
||||
is_graphic_design: false,
|
||||
disable: false,
|
||||
project_id: @project.id)
|
||||
interactor = Repositories::EntriesInteractor.call(@owner, @project.identifier, ".gitea/workflows/#{file}", ref: @project.default_branch)
|
||||
if interactor.success?
|
||||
pipeline.yaml = decode64_content(interactor.result, @owner, @project.repository, @project.default_branch, nil)
|
||||
end
|
||||
pipeline.user_id = current_user.id
|
||||
pipeline.save
|
||||
# 导入的流水线统一先禁用
|
||||
$gitea_hat_client.post_repos_actions_disable(@project&.owner&.login, @project&.identifier, {query: {workflow: file}}) rescue nil
|
||||
end
|
||||
# unless db_files.include?(".gitea/workflows/#{file}")
|
||||
# pipeline = Action::Pipeline.find_or_initialize_by(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""),
|
||||
# file_name: ".gitea/workflows/#{file}",
|
||||
# branch: @project.default_branch,
|
||||
# is_graphic_design: false,
|
||||
# disable: false,
|
||||
# project_id: @project.id)
|
||||
# interactor = Repositories::EntriesInteractor.call(@owner, @project.identifier, ".gitea/workflows/#{file}", ref: @project.default_branch)
|
||||
# if interactor.success?
|
||||
# pipeline.yaml = decode64_content(interactor.result, @owner, @project.repository, @project.default_branch, nil)
|
||||
# end
|
||||
# pipeline.user_id = current_user.id
|
||||
# pipeline.save
|
||||
# # 导入的流水线统一先禁用
|
||||
# $gitea_hat_client.post_repos_actions_disable(@project&.owner&.login, @project&.identifier, {query: {workflow: file}}) rescue nil
|
||||
# end
|
||||
last_action_run = @action_runs.where(workflow_id: file).order(updated: :desc).first
|
||||
last_action_run_json = last_action_run.present? ? {
|
||||
id: last_action_run.id,
|
||||
|
|
|
|||
Loading…
Reference in New Issue