构建流水线yaml base64

This commit is contained in:
xxq250 2024-05-23 10:44:48 +08:00
parent 15513718f9
commit 8760e46c4b
1 changed files with 1 additions and 4 deletions

View File

@ -18,7 +18,6 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
@pipeline.yaml = pipeline_yaml
@pipeline.save!
sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch)
Rails.logger.info "sha==========#{sha}"
tip_exception("#{@pipeline.file_name}已存在") if sha
interactor = Gitea::CreateFileInteractor.call(current_user.gitea_token, @owner.login, content_params)
tip_exception(interactor.error) unless interactor.success?
@ -34,8 +33,6 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
tip_exception("流水线yaml内空不能为空") if pipeline_yaml.blank?
@pipeline.yaml = pipeline_yaml
sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch)
Rails.logger.info "sha==========#{sha}"
Rails.logger.info "sha==========#{sha.present?}"
interactor = sha.present? ? Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params) : Gitea::CreateFileInteractor.call(current_user.gitea_token, @owner.login, content_params)
tip_exception(interactor.error) unless interactor.success?
render_ok
@ -147,7 +144,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
filepath: ".gitea/workflows/#{URI.parse(@pipeline.pipeline_name)}.yaml",
branch: @pipeline.branch,
new_branch: @pipeline.branch,
content: @pipeline.yaml,
content: Base64.encode64(@pipeline.yaml),
message: 'create pipeline',
committer: {
email: current_user.mail,