Class: Modulorails::GitlabciGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/modulorails/gitlabci/gitlabci_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_config_fileObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/generators/modulorails/gitlabci/gitlabci_generator.rb', line 10

def create_config_file
  @data = Modulorails.data
  @image_name = @data.name.parameterize
  @environment_name = @data.environment_name
  @adapter = @data.adapter
  @review_base_url = @data.review_base_url
  @staging_url = @data.staging_url
  @production_url = @data.production_url

  # Update the gitlab-ci template
  template '.gitlab-ci.yml'
  template 'config/deploy/production.yaml' if @production_url.present?
  template 'config/deploy/staging.yaml' if @staging_url.present?
  template 'config/deploy/review.yaml' if @review_base_url.present?

  # Remove the database-ci template if it exists.
  # It used to be referenced by the gitlab-ci template.
  remove_file 'config/database-ci.yml'

  # Create file to avoid this generator on next modulorails launch
  create_keep_file
rescue StandardError => e
  warn("[Modulorails] Error: cannot generate CI configuration: #{e.message}")
end