From a26bbf35c5b742c63044d1a4b3cf0d5f5cdca846 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 24 Jan 2025 09:42:45 +0800 Subject: [PATCH] =?UTF-8?q?fixed:=20=E6=B5=81=E6=B0=B4=E7=BA=BF=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E6=9F=A5=E8=AF=A2=E8=BF=90=E8=A1=8C=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E6=88=90=E4=B8=80=E7=BB=B4=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=96=B9=E4=BE=BF=E4=BD=BF=E7=94=A8,=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v1/projects/actions/actions_controller.rb | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/v1/projects/actions/actions_controller.rb b/app/controllers/api/v1/projects/actions/actions_controller.rb index 0d7d51336..5d494d288 100644 --- a/app/controllers/api/v1/projects/actions/actions_controller.rb +++ b/app/controllers/api/v1/projects/actions/actions_controller.rb @@ -31,18 +31,26 @@ class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions failure += v if k[0] == file && k[1] == 2 end + pipeline_type = 1 + begin + content = Gitea::Repository::Entries::GetService.call(@project&.owner, @project&.identifier, URI.escape(file), ref: last_action_run.present? ? last_action_run.gsub("refs/heads/","") : @project.default_branch)['content'] + yaml_string = Base64.decode64(content).force_encoding("GBK").encode("UTF-8") unless Base64.decode64(content).force_encoding('UTF-8').valid_encoding? + yaml_string = Base64.decode64(content).force_encoding('UTF-8') + yml = YAML.safe_load(yaml_string) + pipeline_type = yml.name == file.to_s.gsub(".yml","").gsub(".yaml","") ? 2 : 1 + rescue + Rails.logger.info("#{file}不能识别流水线类型") + end @result << { - name: file, - last_action_run: last_action_run_json, - history: { - total: total, - success: success, - failure: failure, - } - } + name: file.to_s.gsub(".yml","").gsub(".yaml","") , + branch: last_action_run.present? ? last_action_run.gsub("refs/heads/","") : @project.default_branch, + pipeline_type: pipeline_type, + total: total, + success: success, + failure: failure + }.merge(last_action_run_json) end - - render :json => @result + render :json => {data: @result} end def index