From d8b9de87e621256b5411db6402d740f3fb395ccb Mon Sep 17 00:00:00 2001 From: xxq250 Date: Tue, 4 Nov 2025 17:24:04 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E4=BB=93=E5=BA=93=E4=B8=AD=E5=B7=B2?= =?UTF-8?q?=E6=9C=89=E6=B5=81=E6=B0=B4=E7=BA=BF=E6=96=87=E4=BB=B6=E4=B8=8D?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E5=8A=A0=E5=85=A5=E5=88=B0=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/pm/pipelines_controller.rb | 32 ++++++++++--------- .../api/v1/projects/pipelines_controller.rb | 1 + 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/app/controllers/api/pm/pipelines_controller.rb b/app/controllers/api/pm/pipelines_controller.rb index 1ad0fe085..3f7f752e3 100644 --- a/app/controllers/api/pm/pipelines_controller.rb +++ b/app/controllers/api/pm/pipelines_controller.rb @@ -19,21 +19,23 @@ class Api::Pm::PipelinesController < Api::Pm::BaseController file = file_info.workflow_id project = Project.find_by(gpid: file_info.repo_id) next if project.blank? - 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, - 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, + # 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) + # file = interactor.result + # pipeline.sha = file['content']['sha'] + # 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(repo_id: project.gpid).where(workflow_id: file).order(updated: :desc).first last_action_run_json = last_action_run.present? ? { id: last_action_run.id, diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 380874d23..9b2bedd06 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -116,6 +116,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController file = interactor.result @pipeline.user_id = current_user.id if @pipeline.user_id.blank? @pipeline.pipeline_type = @pipeline.json.present? ? 2 : 1 + @pipeline.sha = sha.present? ? sha : file['content']['sha'] @pipeline.save render_ok({ pipeline_yaml: pipeline_yaml, pipeline_name: @pipeline.pipeline_name, file_name: @pipeline.file_name, sha: sha.present? ? sha : file['content']['sha'] }) end