# frozen_string_literal: true require "rails/generators" module RailsTemplate18f module Generators class GithubActionsGenerator < ::Rails::Generators::Base include Base include PipelineOptions class_option :node_version, desc: "Node version to test against in actions" desc <<~DESC Description: Install Github Actions workflow files DESC def install_actions directory "github", ".github" if !terraform? remove_file ".github/workflows/terraform-staging.yml" remove_file ".github/workflows/terraform-production.yml" end end 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 def update_boundary_diagram boundary_filename = "doc/compliance/apps/application.boundary.md" insert_into_file boundary_filename, <