Class: RailsTemplate18f::Generators::GitlabCiGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Base, CloudGovOptions
Defined in:
lib/generators/rails_template18f/gitlab_ci/gitlab_ci_generator.rb

Instance Method Summary collapse

Instance Method Details

#install_actionsObject



19
20
21
22
# File 'lib/generators/rails_template18f/gitlab_ci/gitlab_ci_generator.rb', line 19

def install_actions
  template "gitlab-ci.yml", ".gitlab-ci.yml"
  directory "gitlab", ".gitlab"
end

#update_boundary_diagramObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/generators/rails_template18f/gitlab_ci/gitlab_ci_generator.rb', line 49

def update_boundary_diagram
  boundary_filename = "doc/compliance/apps/application.boundary.md"
  insert_into_file boundary_filename, <<EOB, after: "Boundary(cicd, \"CI/CD Pipeline\") {\n"
    System_Ext(gitlabci, "GitLab w/ DevTools Runner", "GSA-controlled code repository and Continuous Integration Service")
EOB
  insert_into_file boundary_filename, <<~EOB, before: "@enduml"
    Rel(developer, gitlabci, "Publish code", "git ssh (22)")
    Rel(gitlabci, cg_api, "Deploy App", "Auth: SpaceDeployer Service Account, https (443)")
  EOB
end

#update_readmeObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/generators/rails_template18f/gitlab_ci/gitlab_ci_generator.rb', line 24

def update_readme
  if file_content("README.md").match?(/^## CI\/CD$/)
    insert_into_file "README.md", readme_cicd, after: "## CI/CD\n"
    insert_into_file "README.md", readme_staging_deploy, after: "#### Staging\n"
    insert_into_file "README.md", readme_prod_deploy, after: "#### Production\n"
    insert_into_file "README.md", readme_credentials, after: "#### Credentials and other Secrets\n"
  else
    append_to_file "README.md", <<~EOM
      ## CI/CD
      #{readme_cicd}

      ### Deployment

      #### Staging
      #{readme_staging_deploy}

      #### Production
      #{readme_prod_deploy}

      #### Credentials and other Secrets
      #{readme_credentials}
    EOM
  end
end