构建流水线yaml 更新文件需要sha
This commit is contained in:
parent
8760e46c4b
commit
da831ec6e7
|
@ -33,7 +33,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
|
||||||
tip_exception("流水线yaml内空不能为空") if pipeline_yaml.blank?
|
tip_exception("流水线yaml内空不能为空") if pipeline_yaml.blank?
|
||||||
@pipeline.yaml = pipeline_yaml
|
@pipeline.yaml = pipeline_yaml
|
||||||
sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch)
|
sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch)
|
||||||
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)
|
interactor = sha.present? ? Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params.merge(sha: sha)) : Gitea::CreateFileInteractor.call(current_user.gitea_token, @owner.login, content_params)
|
||||||
tip_exception(interactor.error) unless interactor.success?
|
tip_exception(interactor.error) unless interactor.success?
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
|
@ -49,8 +49,16 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@pipeline = Action::Pipeline.find(params[:id])
|
@pipeline = Action::Pipeline.find(params[:id])
|
||||||
@pipeline.update!(pipeline_name: params[:pipeline_name])
|
@pipeline.pipeline_name = params[:pipeline_name]
|
||||||
interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params)
|
@pipeline.file_name = ".gitea/workflows/#{@pipeline.pipeline_name}.yaml"
|
||||||
|
@pipeline.branch = params[:branch] || @project.default_branch
|
||||||
|
@pipeline.json = params[:pipeline_json].to_json
|
||||||
|
pipeline_yaml = build_pipeline_yaml(params[:pipeline_name], params[:pipeline_json])
|
||||||
|
tip_exception("流水线yaml内空不能为空") if pipeline_yaml.blank?
|
||||||
|
@pipeline.yaml = pipeline_yaml
|
||||||
|
@pipeline.save
|
||||||
|
sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch)
|
||||||
|
interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params.merge(sha: sha))
|
||||||
tip_exception(interactor.error) unless interactor.success?
|
tip_exception(interactor.error) unless interactor.success?
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue