ADD get .trustie-pipeline.yml file api with devops

This commit is contained in:
Jasder
2020-07-22 11:18:02 +08:00
parent a22bd280bc
commit 1c2264f721
3 changed files with 51 additions and 0 deletions

View File

@@ -1,4 +1,6 @@
class ::DevOps::BuildsController < ApplicationController
include RepositoriesHelper
before_action :require_login
before_action :find_repo
@@ -36,6 +38,19 @@ class ::DevOps::BuildsController < ApplicationController
render json: result
end
# get .trustie-pipeline.yml file
def get_trustie_pipeline
file_path_uri = URI.parse('.trustie-pipeline.yml')
interactor = Repositories::EntriesInteractor.call(@repo.user, @repo.identifier, file_path_uri, ref: params[:ref] || "master")
if interactor.success?
file = interactor.result
return render json: {} if file[:status]
json = {name: file['name'], path: file['path'], content: render_decode64_content(file['content'])}
render json: json
end
end
private
def find_repo
@repo = ::Repository.find params[:id]