diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 107bd357c..5aa62caab 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -139,8 +139,11 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController def destroy @pipeline = Action::Pipeline.find(params[:id]) if @pipeline - interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, del_content_params.merge(identifier: @project.identifier)) - tip_exception(interactor.error) unless interactor.success? + sha = get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch) + if sha.present? + interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @owner.login, del_content_params(sha).merge(identifier: @project.identifier)) + tip_exception(interactor.error) unless interactor.success? + end @pipeline.destroy! end render_ok @@ -230,12 +233,12 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController } end - def del_content_params + def del_content_params(sha) { filepath: ".gitea/workflows/#{@pipeline.pipeline_name}.yml", base64_filepath: Base64.encode64(".gitea/workflows/#{@pipeline.pipeline_name}.yml").gsub(/\n/, ''), branch: @pipeline.branch, - sha: get_pipeline_file_sha(@pipeline.file_name, @pipeline.branch) + sha: sha } end