Class: GoogleCloud::GeneratePipelineService

Inherits:
BaseService show all
Defined in:
app/services/google_cloud/generate_pipeline_service.rb

Constant Summary collapse

ACTION_DEPLOY_TO_CLOUD_RUN =
'DEPLOY_TO_CLOUD_RUN'
ACTION_DEPLOY_TO_CLOUD_STORAGE =
'DEPLOY_TO_CLOUD_STORAGE'
ACTION_VISION_AI_PIPELINE =
'VISION_AI_PIPELINE'

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/services/google_cloud/generate_pipeline_service.rb', line 9

def execute
  commit_attributes = generate_commit_attributes
  create_branch_response = ::Branches::CreateService.new(project, current_user)
                                                    .execute(commit_attributes[:branch_name], project.default_branch)

  if create_branch_response[:status] == :error
    return create_branch_response
  end

  branch = create_branch_response[:branch]

  service = default_branch_gitlab_ci_yml.present? ? ::Files::UpdateService : ::Files::CreateService

  commit_response = service.new(project, current_user, commit_attributes).execute

  if commit_response[:status] == :error
    return commit_response
  end

  success({ branch_name: branch.name, commit: commit_response })
end