|
|
|
@@ -47,6 +47,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController |
|
|
|
interactor = sha.present? ? Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("update").merge(sha: sha)) : Gitea::CreateFileInteractor.call(current_user.gitea_token, @owner.login, content_params("create")) |
|
|
|
tip_exception(interactor.error) unless interactor.success? |
|
|
|
file = interactor.result |
|
|
|
@pipeline.save |
|
|
|
render_ok({ pipeline_yaml: pipeline_yaml, pipeline_name: params[:pipeline_name], file_name: @pipeline.file_name, sha: sha.present? ? sha : file['content']['sha'] }) |
|
|
|
end |
|
|
|
|
|
|
|
@@ -79,8 +80,8 @@ 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, content_params("update")) |
|
|
|
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? |
|
|
|
@pipeline.destroy! |
|
|
|
end |
|
|
|
@@ -114,7 +115,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController |
|
|
|
|
|
|
|
def show |
|
|
|
@pipeline = Action::Pipeline.find_by(id: params[:id]) |
|
|
|
@pipeline = Action::Pipeline.new(id: 0, pipeline_name: "test-ss", yaml: build_test_yaml) if @pipeline.blank? |
|
|
|
# @pipeline = Action::Pipeline.new(id: 0, pipeline_name: "test-ss", yaml: build_test_yaml) if @pipeline.blank? |
|
|
|
end |
|
|
|
|
|
|
|
def build_pipeline_yaml_new(pipeline_name, pipeline_json) |
|
|
|
@@ -172,6 +173,15 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController |
|
|
|
} |
|
|
|
end |
|
|
|
|
|
|
|
def del_content_params(opt) |
|
|
|
{ |
|
|
|
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) |
|
|
|
} |
|
|
|
end |
|
|
|
|
|
|
|
def build_nodes(params_nodes) |
|
|
|
steps_nodes = [] |
|
|
|
params_nodes.each do |input_node| |
|
|
|
|