rails_template_18f 1.3.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +64 -61
- data/README.md +11 -16
- data/lib/generators/rails_template18f/active_storage/active_storage_generator.rb +7 -6
- data/lib/generators/rails_template18f/circleci/circleci_generator.rb +28 -27
- data/lib/generators/rails_template18f/circleci/templates/Dockerfile.ci.tt +0 -1
- data/lib/generators/rails_template18f/circleci/templates/circleci/config.yml.tt +162 -163
- data/lib/generators/rails_template18f/cloud_gov_config/templates/app/models/cloud_gov_config.rb +9 -1
- data/lib/generators/rails_template18f/github_actions/github_actions_generator.rb +31 -30
- data/lib/generators/rails_template18f/github_actions/templates/github/actions/compile-assets/action.yml +50 -0
- data/lib/generators/rails_template18f/github_actions/templates/github/actions/setup-project/action.yml.tt +4 -8
- data/lib/generators/rails_template18f/github_actions/templates/github/dependabot.yml.tt +2 -4
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml +74 -0
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml +74 -0
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/owasp-daily-scan.yml.tt +10 -1
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/owasp-scan.yml.tt +1 -1
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/pa11y.yml.tt +2 -2
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-production.yml +49 -4
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-staging.yml +49 -4
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/validate-ssp.yml +2 -2
- data/lib/generators/rails_template18f/gitlab_ci/gitlab_ci_generator.rb +147 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/node.yml.tt +11 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/rails.yml +75 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/ruby.yml +7 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/terraform.yml +28 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab-ci.yml.tt +212 -0
- data/lib/generators/rails_template18f/i18n_js/i18n_js_generator.rb +2 -2
- data/lib/generators/rails_template18f/i18n_js/templates/app/javascript/{i18n.js → i18n/index.js} +1 -1
- data/lib/generators/rails_template18f/i18n_js/templates/config/i18n-js.yml +1 -1
- data/lib/generators/rails_template18f/newrelic/newrelic_generator.rb +4 -2
- data/lib/generators/rails_template18f/public_egress/public_egress_generator.rb +71 -55
- data/lib/generators/rails_template18f/sidekiq/sidekiq_generator.rb +8 -17
- data/lib/generators/rails_template18f/terraform/templates/full_bootstrap/imports.tf.tftpl +25 -0
- data/lib/generators/rails_template18f/terraform/templates/full_bootstrap/main.tf.tt +159 -0
- data/lib/generators/rails_template18f/terraform/templates/sandbox_bootstrap/imports.tf.tftpl +10 -0
- data/lib/generators/rails_template18f/terraform/templates/sandbox_bootstrap/main.tf.tt +117 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/README.md.tt +69 -95
- data/lib/generators/rails_template18f/terraform/templates/terraform/app.tf.tt +57 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/apply.sh +15 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/templates/backend_config.tftpl +8 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/templates/bot_secrets.tftpl +5 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/users.auto.tfvars +5 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/main.tf.tt +117 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/production.tfvars.tt +13 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/providers.tf.tt +18 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/staging.tfvars.tt +8 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/terraform.sh.tt +95 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/variables.tf.tt +98 -0
- data/lib/generators/rails_template18f/terraform/terraform_generator.rb +12 -4
- data/lib/rails_template18f/generators/cloud_gov_options.rb +9 -6
- data/lib/rails_template18f/generators/cloud_gov_parsing.rb +7 -7
- data/lib/rails_template18f/generators.rb +0 -1
- data/lib/rails_template18f/version.rb +1 -1
- data/rails-template-18f.gemspec +4 -4
- data/railsrc +4 -2
- data/railsrc-hotwire +4 -2
- data/template.rb +80 -82
- data/templates/README.md.tt +21 -8
- data/templates/app/assets/stylesheets/uswds-settings.scss +3 -2
- data/templates/app/views/application/_header.html.erb +1 -1
- data/templates/app/views/application/_usa_banner.html.erb +3 -3
- data/templates/bin/ops/create_service_account.sh.tt +20 -11
- data/templates/bin/ops/destroy_service_account.sh.tt +3 -3
- data/templates/browserslistrc +1 -2
- data/templates/doc/compliance/TODO.md +1 -4
- data/templates/{pa11yci.js → pa11yci.js.tt} +5 -0
- metadata +36 -35
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml.tt +0 -50
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml.tt +0 -50
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/import.sh +0 -13
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/main.tf.tt +0 -22
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/providers.tf +0 -16
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/run.sh.tt +0 -40
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/teardown_creds.sh.tt +0 -5
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/variables.tf +0 -2
- data/lib/generators/rails_template18f/terraform/templates/terraform/production/main.tf.tt +0 -90
- data/lib/generators/rails_template18f/terraform/templates/terraform/production/providers.tf +0 -23
- data/lib/generators/rails_template18f/terraform/templates/terraform/production/variables.tf +0 -2
- data/lib/generators/rails_template18f/terraform/templates/terraform/staging/main.tf.tt +0 -70
- data/lib/generators/rails_template18f/terraform/templates/terraform/staging/providers.tf +0 -23
- data/lib/generators/rails_template18f/terraform/templates/terraform/staging/variables.tf +0 -2
- data/lib/rails_template18f/generators/pipeline_options.rb +0 -18
- data/templates/app/assets/images/uswds.js +0 -6
- data/templates/config/deployment/production.yml +0 -3
- data/templates/config/deployment/staging.yml +0 -3
- data/templates/manifest.yml.tt +0 -17
@@ -1,10 +1,10 @@
|
|
1
1
|
version: 2.1
|
2
2
|
|
3
3
|
orbs:
|
4
|
-
ruby: circleci/ruby@2.1
|
5
|
-
node: circleci/node@
|
6
|
-
browser-tools: circleci/browser-tools@1.
|
7
|
-
terraform: circleci/terraform@3.
|
4
|
+
ruby: circleci/ruby@2.3.1
|
5
|
+
node: circleci/node@7.0.0
|
6
|
+
browser-tools: circleci/browser-tools@1.5.0
|
7
|
+
terraform: circleci/terraform@3.5.0
|
8
8
|
|
9
9
|
commands:
|
10
10
|
setup-project:
|
@@ -15,7 +15,51 @@ commands:
|
|
15
15
|
install-yarn: true
|
16
16
|
- node/install-packages:
|
17
17
|
cache-only-lockfile: false
|
18
|
-
pkg-manager: yarn
|
18
|
+
pkg-manager: yarn
|
19
|
+
compile-assets:
|
20
|
+
description: Restore asset cache and compile, optionally saving back to the cache
|
21
|
+
parameters:
|
22
|
+
rails_env:
|
23
|
+
description: RAILS_ENV to use for precompilation
|
24
|
+
type: string
|
25
|
+
restore_only:
|
26
|
+
description: Whether to skip compilation and cleaning
|
27
|
+
type: boolean
|
28
|
+
default: false
|
29
|
+
save_cache:
|
30
|
+
description: Whether to save the resulting asset cache
|
31
|
+
type: boolean
|
32
|
+
default: true
|
33
|
+
steps:
|
34
|
+
# Precompile assets
|
35
|
+
# Load assets from cache if possible, precompile assets then save cache
|
36
|
+
# Multiple caches are used to increase the chance of a cache hit
|
37
|
+
# https://circleci.com/docs/2.0/caching/#full-example-of-saving-and-restoring-cache
|
38
|
+
- restore_cache:
|
39
|
+
keys:
|
40
|
+
- asset-cache-v1-<< parameters.rails_env >>-{{ .Branch }}
|
41
|
+
- asset-cache-v1-<< parameters.rails_env >>
|
42
|
+
- when:
|
43
|
+
condition:
|
44
|
+
equal: [ false, << parameters.restore_only >> ]
|
45
|
+
steps:
|
46
|
+
- run:
|
47
|
+
environment:
|
48
|
+
RAILS_ENV: << parameters.rails_env >>
|
49
|
+
SECRET_KEY_BASE_DUMMY: 1
|
50
|
+
command: ./bin/rake assets:precompile
|
51
|
+
- run:
|
52
|
+
envronment:
|
53
|
+
RAILS_ENV: << parameters.rails_env >>
|
54
|
+
SECRET_KEY_BASE_DUMMY: 1
|
55
|
+
command: ./bin/rake assets:clean
|
56
|
+
- when:
|
57
|
+
condition: << parameters.save_cache >>
|
58
|
+
steps:
|
59
|
+
- save_cache:
|
60
|
+
key: asset-cache-v1-<< parameters.rails_env >>-{{ .Branch }}-{{ checksum "public/assets/.manifest.json" }}
|
61
|
+
paths:
|
62
|
+
- public/assets<% if oscal_dir_exists? %>
|
19
63
|
trestle-cmd:
|
20
64
|
description: Set up environment for running docker-trestle commands
|
21
65
|
parameters:
|
@@ -30,58 +74,6 @@ commands:
|
|
30
74
|
- run:
|
31
75
|
name: Run trestle command
|
32
76
|
command: docker run -u "$(id -u):$(id -g)" -v $(pwd)/doc/compliance/oscal:/app/docs:rw ghcr.io/gsa-tts/trestle:<< parameters.tag >> << parameters.cmd >><% end %>
|
33
|
-
cg-deploy:
|
34
|
-
description: "Login to cloud foundry space with service account credentials
|
35
|
-
and push application using deployment configuration file."
|
36
|
-
parameters:
|
37
|
-
cloudgov_username:
|
38
|
-
description: "Name of CircleCI project environment variable that
|
39
|
-
holdes deployer username for cloudgov space"
|
40
|
-
type: env_var_name
|
41
|
-
cloudgov_password:
|
42
|
-
description: "Name of CircleCI project environment variable that
|
43
|
-
holds deployer password for cloudgov space"
|
44
|
-
type: env_var_name
|
45
|
-
cloudgov_org:
|
46
|
-
description: "cloud.gov organization name"
|
47
|
-
type: string
|
48
|
-
cloudgov_space:
|
49
|
-
description: "cloud.gov space name"
|
50
|
-
type: string
|
51
|
-
deploy_config_file:
|
52
|
-
description: "Path to deployment configuration file"
|
53
|
-
type: string
|
54
|
-
rails_master_key:
|
55
|
-
description: "Name of CircleCI project environment variable holding the RAILS_MASTER_KEY"
|
56
|
-
type: env_var_name
|
57
|
-
steps:
|
58
|
-
- run:
|
59
|
-
name: Vendor gems
|
60
|
-
command: bundle cache --all
|
61
|
-
- run:
|
62
|
-
name: Install Cloud Foundry CLI
|
63
|
-
command: |
|
64
|
-
curl -v -L -o cf-cli_amd64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=v8&source=github'
|
65
|
-
sudo dpkg -i cf-cli_amd64.deb
|
66
|
-
- run:
|
67
|
-
name: Login with service account
|
68
|
-
command: |
|
69
|
-
cf login -a api.fr.cloud.gov \
|
70
|
-
-u ${<< parameters.cloudgov_username >>} \
|
71
|
-
-p ${<< parameters.cloudgov_password >>} \
|
72
|
-
-o << parameters.cloudgov_org >> \
|
73
|
-
-s << parameters.cloudgov_space >>
|
74
|
-
- run:
|
75
|
-
name: Set restricted egress
|
76
|
-
command: |
|
77
|
-
cf bind-security-group trusted_local_networks_egress << parameters.cloudgov_org >> \
|
78
|
-
--space << parameters.cloudgov_space >>
|
79
|
-
- run:
|
80
|
-
name: Push application with deployment vars
|
81
|
-
command: |
|
82
|
-
cf push --strategy rolling \
|
83
|
-
--vars-file << parameters.deploy_config_file >> \
|
84
|
-
--var rails_master_key=${<< parameters.rails_master_key >>}
|
85
77
|
|
86
78
|
jobs:
|
87
79
|
build:
|
@@ -89,6 +81,8 @@ jobs:
|
|
89
81
|
- image: cimg/ruby:<%= ruby_version %>
|
90
82
|
steps:
|
91
83
|
- setup-project
|
84
|
+
- compile-assets:
|
85
|
+
rails_env: ci
|
92
86
|
|
93
87
|
test:
|
94
88
|
parallelism: 3
|
@@ -116,25 +110,8 @@ jobs:
|
|
116
110
|
- run:
|
117
111
|
name: Database setup
|
118
112
|
command: bundle exec rails db:schema:load --trace
|
119
|
-
|
120
|
-
|
121
|
-
# Load assets from cache if possible, precompile assets then save cache
|
122
|
-
# Multiple caches are used to increase the chance of a cache hit
|
123
|
-
# https://circleci.com/docs/2.0/caching/#full-example-of-saving-and-restoring-cache
|
124
|
-
- restore_cache:
|
125
|
-
keys:
|
126
|
-
- asset-cache-v1-{{ .Environment.RAILS_ENV }}-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
127
|
-
- asset-cache-v1-{{ .Environment.RAILS_ENV }}-{{ arch }}-{{ .Branch }}
|
128
|
-
- asset-cache-v1-{{ .Environment.RAILS_ENV }}
|
129
|
-
|
130
|
-
- run: bundle exec rake assets:precompile
|
131
|
-
|
132
|
-
- save_cache:
|
133
|
-
key: asset-cache-v1-{{ .Environment.RAILS_ENV }}-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
134
|
-
paths:
|
135
|
-
- public/assets
|
136
|
-
- tmp/cache/assets/sprockets
|
137
|
-
|
113
|
+
- compile-assets:
|
114
|
+
rails_env: test
|
138
115
|
- ruby/rspec-test
|
139
116
|
<% if oscal_dir_exists? %>
|
140
117
|
validate_ssp:
|
@@ -203,6 +180,9 @@ jobs:
|
|
203
180
|
- restore_cache:
|
204
181
|
keys:
|
205
182
|
- node-deps-{{ arch }}-v1-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
|
183
|
+
- compile-assets:
|
184
|
+
rails_env: ci
|
185
|
+
restore_only: true
|
206
186
|
|
207
187
|
- run:
|
208
188
|
name: Start up local server
|
@@ -233,6 +213,9 @@ jobs:
|
|
233
213
|
- restore_cache:
|
234
214
|
keys:
|
235
215
|
- node-deps-{{ arch }}-v1-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
|
216
|
+
- compile-assets:
|
217
|
+
rails_env: ci
|
218
|
+
restore_only: true
|
236
219
|
|
237
220
|
- run:
|
238
221
|
name: Start up local server
|
@@ -275,23 +258,9 @@ jobs:
|
|
275
258
|
name: Database setup
|
276
259
|
command: bundle exec rails db:schema:load --trace
|
277
260
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
# https://circleci.com/docs/2.0/caching/#full-example-of-saving-and-restoring-cache
|
282
|
-
- restore_cache:
|
283
|
-
keys:
|
284
|
-
- asset-cache-v1-{{ .Environment.RAILS_ENV }}-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
285
|
-
- asset-cache-v1-{{ .Environment.RAILS_ENV }}-{{ arch }}-{{ .Branch }}
|
286
|
-
- asset-cache-v1-{{ .Environment.RAILS_ENV }}
|
287
|
-
|
288
|
-
- run: bundle exec rake assets:precompile
|
289
|
-
|
290
|
-
- save_cache:
|
291
|
-
key: asset-cache-v1-{{ .Environment.RAILS_ENV }}-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
292
|
-
paths:
|
293
|
-
- public/assets
|
294
|
-
- tmp/cache/assets/sprockets
|
261
|
+
- compile-assets:
|
262
|
+
rails_env: ci
|
263
|
+
save_cache: false
|
295
264
|
|
296
265
|
- run:
|
297
266
|
name: Start server
|
@@ -305,27 +274,59 @@ jobs:
|
|
305
274
|
- run:
|
306
275
|
name: Run pa11y-ci
|
307
276
|
command: yarn run pa11y-ci -c pa11yci.js
|
308
|
-
|
277
|
+
|
278
|
+
refresh_asset_caches:
|
279
|
+
docker:
|
280
|
+
- image: cimg/ruby:<%= ruby_version %>
|
281
|
+
steps:
|
282
|
+
- setup-project
|
283
|
+
- compile-assets:
|
284
|
+
rails_env: staging
|
285
|
+
restore_only: true<% if terraform_manage_spaces? %>
|
286
|
+
- compile-assets:
|
287
|
+
rails_env: production
|
288
|
+
restore_only: true<% end %>
|
289
|
+
compile_staging_assets:
|
290
|
+
docker:
|
291
|
+
- image: cimg/ruby:<%= ruby_version %>
|
292
|
+
steps:
|
293
|
+
- setup-project
|
294
|
+
- compile-assets:
|
295
|
+
rails_env: staging
|
296
|
+
- persist_to_workspace:
|
297
|
+
root: .
|
298
|
+
paths:
|
299
|
+
- public/assets
|
309
300
|
terraform_plan_staging:
|
310
301
|
executor: terraform/default
|
311
302
|
steps:
|
312
303
|
- checkout
|
313
304
|
- terraform/init:
|
314
|
-
path: terraform
|
305
|
+
path: terraform
|
306
|
+
backend_config: >-
|
307
|
+
key=terraform.tfstate.staging,
|
308
|
+
bucket=$TERRAFORM_STATE_BUCKET_NAME
|
315
309
|
- terraform/validate:
|
316
|
-
path: terraform
|
310
|
+
path: terraform
|
317
311
|
- terraform/fmt:
|
318
|
-
path: terraform
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
command: echo -e "cf_user = \"$CF_STAGING_USERNAME\"\ncf_password = \"$CF_STAGING_PASSWORD\"" > secrets.auto.tfvars
|
312
|
+
path: terraform
|
313
|
+
recursive: true
|
314
|
+
- attach_workspace:
|
315
|
+
at: .
|
323
316
|
- terraform/plan:
|
324
|
-
|
317
|
+
environment:
|
318
|
+
CF_API_URL: "https://api.fr.cloud.gov"
|
319
|
+
CF_USER: "$CF_USERNAME"
|
320
|
+
path: terraform
|
321
|
+
out: staging.out
|
322
|
+
var_file: staging.tfvars
|
323
|
+
var: >-
|
324
|
+
rails_master_key="$RAILS_MASTER_KEY",
|
325
|
+
cf_user="$CF_USERNAME",
|
325
326
|
- persist_to_workspace:
|
326
327
|
root: .
|
327
328
|
paths:
|
328
|
-
- ./terraform
|
329
|
+
- ./terraform
|
329
330
|
terraform_apply_staging:
|
330
331
|
executor: terraform/default
|
331
332
|
steps:
|
@@ -333,27 +334,48 @@ jobs:
|
|
333
334
|
- attach_workspace:
|
334
335
|
at: .
|
335
336
|
- terraform/apply:
|
336
|
-
|
337
|
+
environment:
|
338
|
+
CF_API_URL: "https://api.fr.cloud.gov"
|
339
|
+
CF_USER: "$CF_USERNAME"
|
340
|
+
path: terraform
|
341
|
+
plan: staging.out<% if terraform_manage_spaces? %>
|
342
|
+
|
343
|
+
compile_production_assets:
|
344
|
+
docker:
|
345
|
+
- image: cimg/ruby:<%= ruby_version %>
|
346
|
+
steps:
|
347
|
+
- setup-project
|
348
|
+
- compile-assets:
|
349
|
+
rails_env: production
|
350
|
+
- persist_to_workspace:
|
351
|
+
root: .
|
352
|
+
paths:
|
353
|
+
- public/assets
|
337
354
|
terraform_plan_production:
|
338
355
|
executor: terraform/default
|
339
356
|
steps:
|
340
357
|
- checkout
|
341
358
|
- terraform/init:
|
342
|
-
path: terraform
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
name: Set terraform variables
|
349
|
-
working_directory: terraform/production
|
350
|
-
command: echo -e "cf_user = \"$CF_PRODUCTION_USERNAME\"\ncf_password = \"$CF_PRODUCTION_PASSWORD\"" > secrets.auto.tfvars
|
359
|
+
path: terraform
|
360
|
+
backend_config: >-
|
361
|
+
key=terraform.tfstate.production,
|
362
|
+
bucket=$TERRAFORM_STATE_BUCKET_NAME
|
363
|
+
- attach_workspace:
|
364
|
+
at: .
|
351
365
|
- terraform/plan:
|
352
|
-
|
366
|
+
environment:
|
367
|
+
CF_API_URL: "https://api.fr.cloud.gov"
|
368
|
+
CF_USER: "$CF_USERNAME"
|
369
|
+
path: terraform
|
370
|
+
out: production.out
|
371
|
+
var_file: production.tfvars
|
372
|
+
var: >-
|
373
|
+
rails_master_key="$PRODUCTION_RAILS_MASTER_KEY",
|
374
|
+
cf_user="$CF_USERNAME",
|
353
375
|
- persist_to_workspace:
|
354
376
|
root: .
|
355
377
|
paths:
|
356
|
-
- ./terraform
|
378
|
+
- ./terraform
|
357
379
|
terraform_apply_production:
|
358
380
|
executor: terraform/default
|
359
381
|
steps:
|
@@ -361,32 +383,11 @@ jobs:
|
|
361
383
|
- attach_workspace:
|
362
384
|
at: .
|
363
385
|
- terraform/apply:
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
steps:
|
370
|
-
- setup-project
|
371
|
-
- cg-deploy:
|
372
|
-
cloudgov_username: CF_STAGING_USERNAME
|
373
|
-
cloudgov_password: CF_STAGING_PASSWORD
|
374
|
-
cloudgov_org: <%= cloud_gov_organization %>
|
375
|
-
cloudgov_space: <%= cloud_gov_staging_space %>
|
376
|
-
deploy_config_file: config/deployment/staging.yml
|
377
|
-
rails_master_key: RAILS_MASTER_KEY
|
378
|
-
deploy_production:
|
379
|
-
docker:
|
380
|
-
- image: cimg/ruby:<%= ruby_version %>
|
381
|
-
steps:
|
382
|
-
- setup-project
|
383
|
-
- cg-deploy:
|
384
|
-
cloudgov_username: CF_PRODUCTION_USERNAME
|
385
|
-
cloudgov_password: CF_PRODUCTION_PASSWORD
|
386
|
-
cloudgov_org: <%= cloud_gov_organization %>
|
387
|
-
cloudgov_space: <%= cloud_gov_production_space %>
|
388
|
-
deploy_config_file: config/deployment/production.yml
|
389
|
-
rails_master_key: PRODUCTION_RAILS_MASTER_KEY
|
386
|
+
environment:
|
387
|
+
CF_API_URL: "https://api.fr.cloud.gov"
|
388
|
+
CF_USER: "$CF_USERNAME"
|
389
|
+
path: terraform
|
390
|
+
plan: production.out<% end %>
|
390
391
|
|
391
392
|
workflows:
|
392
393
|
version: 2.1
|
@@ -414,18 +415,33 @@ workflows:
|
|
414
415
|
- build
|
415
416
|
- a11y_scan:
|
416
417
|
requires:
|
417
|
-
- build
|
418
|
+
- build
|
419
|
+
- compile_staging_assets:
|
420
|
+
filters:
|
421
|
+
branches:
|
422
|
+
ignore: production
|
418
423
|
- terraform_plan_staging:
|
419
424
|
filters:
|
420
425
|
branches:
|
421
426
|
ignore: production
|
427
|
+
requires:
|
428
|
+
- compile_staging_assets
|
422
429
|
- terraform_apply_staging:
|
423
430
|
filters:
|
424
431
|
branches:
|
425
432
|
only: main
|
426
433
|
requires:
|
427
434
|
- terraform_plan_staging
|
428
|
-
|
435
|
+
- owasp_scan
|
436
|
+
- static_security_scans
|
437
|
+
- test
|
438
|
+
- a11y_scan<% if terraform_manage_spaces? %>
|
439
|
+
production_plan_and_apply:
|
440
|
+
jobs:
|
441
|
+
- compile_production_assets
|
442
|
+
- terraform_plan_production:
|
443
|
+
requires:
|
444
|
+
- compile_production_assets
|
429
445
|
- approve_production_terraform:
|
430
446
|
type: approval
|
431
447
|
filters:
|
@@ -439,26 +455,6 @@ workflows:
|
|
439
455
|
only: production
|
440
456
|
requires:
|
441
457
|
- approve_production_terraform<% end %>
|
442
|
-
- deploy_staging:
|
443
|
-
filters:
|
444
|
-
branches:
|
445
|
-
only: main
|
446
|
-
requires:
|
447
|
-
- test
|
448
|
-
- static_security_scans
|
449
|
-
- owasp_scan
|
450
|
-
- a11y_scan<% if terraform? %>
|
451
|
-
- terraform_apply_staging<% end %>
|
452
|
-
- deploy_production:
|
453
|
-
filters:
|
454
|
-
branches:
|
455
|
-
only: production
|
456
|
-
requires:
|
457
|
-
- test
|
458
|
-
- static_security_scans
|
459
|
-
- owasp_scan
|
460
|
-
- a11y_scan<% if terraform? %>
|
461
|
-
- terraform_apply_production<% end %>
|
462
458
|
daily_scan:
|
463
459
|
triggers:
|
464
460
|
- schedule:
|
@@ -471,6 +467,9 @@ workflows:
|
|
471
467
|
- production
|
472
468
|
jobs:
|
473
469
|
- build
|
470
|
+
- refresh_asset_caches:
|
471
|
+
requires:
|
472
|
+
- build
|
474
473
|
- static_security_scans:
|
475
474
|
requires:
|
476
475
|
- build
|
data/lib/generators/rails_template18f/cloud_gov_config/templates/app/models/cloud_gov_config.rb
CHANGED
@@ -10,6 +10,14 @@ class CloudGovConfig
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.vcap_services
|
13
|
-
|
13
|
+
if Rails.env.test?
|
14
|
+
parse_env
|
15
|
+
else
|
16
|
+
@vcap_services ||= parse_env
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private_class_method def self.parse_env
|
21
|
+
JSON.parse(ENV[ENV_VARIABLE]).with_indifferent_access
|
14
22
|
end
|
15
23
|
end
|
@@ -6,7 +6,7 @@ module RailsTemplate18f
|
|
6
6
|
module Generators
|
7
7
|
class GithubActionsGenerator < ::Rails::Generators::Base
|
8
8
|
include Base
|
9
|
-
include
|
9
|
+
include CloudGovOptions
|
10
10
|
|
11
11
|
class_option :node_version, desc: "Node version to test against in actions"
|
12
12
|
|
@@ -17,14 +17,14 @@ module RailsTemplate18f
|
|
17
17
|
|
18
18
|
def install_actions
|
19
19
|
directory "github", ".github"
|
20
|
-
if !terraform?
|
21
|
-
remove_file ".github/workflows/terraform-staging.yml"
|
22
|
-
remove_file ".github/workflows/terraform-production.yml"
|
23
|
-
end
|
24
20
|
if !oscal_dir_exists?
|
25
21
|
remove_file ".github/workflows/validate-ssp.yml"
|
26
22
|
remove_file ".github/workflows/assemble-ssp.yml"
|
27
23
|
end
|
24
|
+
if !terraform_manage_spaces?
|
25
|
+
remove_file ".github/workflows/terraform-production.yml"
|
26
|
+
remove_file ".github/workflows/deploy-production.yml"
|
27
|
+
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def update_readme
|
@@ -80,8 +80,7 @@ EOB
|
|
80
80
|
def readme_staging_deploy
|
81
81
|
<<~EOM
|
82
82
|
|
83
|
-
Deploys to staging
|
84
|
-
on every push to the `main` branch in GitHub.
|
83
|
+
Deploys to staging happen via terraform on every push to the `main` branch in GitHub.
|
85
84
|
|
86
85
|
The following secrets must be set within the `staging` [environment secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-an-environment)
|
87
86
|
to enable a deploy to work:
|
@@ -96,28 +95,31 @@ EOB
|
|
96
95
|
end
|
97
96
|
|
98
97
|
def readme_prod_deploy
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
98
|
+
if terraform_manage_spaces?
|
99
|
+
<<~EOM
|
100
|
+
|
101
|
+
Deploys to production happen via terraform on every push to the `production` branch in GitHub.
|
102
|
+
|
103
|
+
The following secrets must be set within the `production` [environment secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-an-environment)
|
104
|
+
to enable a deploy to work:
|
105
|
+
|
106
|
+
| Secret Name | Description |
|
107
|
+
| ----------- | ----------- |
|
108
|
+
| `CF_USERNAME` | cloud.gov SpaceDeployer username |
|
109
|
+
| `CF_PASSWORD` | cloud.gov SpaceDeployer password |
|
110
|
+
| `RAILS_MASTER_KEY` | `config/credentials/production.key` |
|
111
|
+
#{terraform_secret_values}
|
112
|
+
EOM
|
113
|
+
else
|
114
|
+
"Production deploys are not supported in the sandbox organization."
|
115
|
+
end
|
114
116
|
end
|
115
117
|
|
116
118
|
def readme_credentials
|
117
119
|
<<~EOM
|
118
120
|
|
119
121
|
1. Store variables that must be secret using [GitHub Environment Secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-an-environment)
|
120
|
-
1. Add the appropriate
|
122
|
+
1. Add the appropriate `TF_VAR_<variable name>` addition to the `terraform-<env>.yml` and `deploy-<env>.yml` workflows like the existing `TF_VAR_rails_master_key`
|
121
123
|
EOM
|
122
124
|
end
|
123
125
|
end
|
@@ -125,12 +127,11 @@ EOB
|
|
125
127
|
private
|
126
128
|
|
127
129
|
def terraform_secret_values
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
130
|
+
<<~EOM
|
131
|
+
| `TERRAFORM_STATE_ACCESS_KEY` | Access key for terraform state bucket |
|
132
|
+
| `TERRAFORM_STATE_SECRET_ACCESS_KEY` | Secret key for terraform state bucket |
|
133
|
+
| `TERRAFORM_STATE_BUCKET_NAME` | Bucket name for terraform state bucket |
|
134
|
+
EOM
|
134
135
|
end
|
135
136
|
|
136
137
|
def node_version
|
@@ -139,7 +140,7 @@ EOB
|
|
139
140
|
elsif File.exist?(nvmrc_path)
|
140
141
|
File.read(nvmrc_path).strip
|
141
142
|
else
|
142
|
-
"16
|
143
|
+
"20.16"
|
143
144
|
end
|
144
145
|
end
|
145
146
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
name: Compile assets
|
2
|
+
description: Restore an asset cache, precompile, clean, and optionally save the cache back
|
3
|
+
inputs:
|
4
|
+
rails_env:
|
5
|
+
description: RAILS_ENV in use.
|
6
|
+
required: true
|
7
|
+
fail_on_missing_cache:
|
8
|
+
description: Whether to fail the action on a missing cache restore
|
9
|
+
required: false
|
10
|
+
default: 'false'
|
11
|
+
save_cache:
|
12
|
+
description: Whether to save the compiled assets cache
|
13
|
+
required: false
|
14
|
+
default: 'false'
|
15
|
+
runs:
|
16
|
+
using: composite
|
17
|
+
steps:
|
18
|
+
- uses: ./.github/actions/setup-languages
|
19
|
+
|
20
|
+
- name: Restore asset cache
|
21
|
+
uses: actions/cache/restore@v4
|
22
|
+
with:
|
23
|
+
key: ${{ inputs.rails_env }}-assets-
|
24
|
+
fail-on-cache-miss: ${{ inputs.fail_on_missing_cache }}
|
25
|
+
path: |
|
26
|
+
public/assets
|
27
|
+
app/assets/builds
|
28
|
+
|
29
|
+
- name: Precompile assets
|
30
|
+
env:
|
31
|
+
RAILS_ENV: ${{ inputs.rails_env }}
|
32
|
+
SECRET_KEY_BASE_DUMMY: 1
|
33
|
+
shell: bash
|
34
|
+
run: ./bin/rake assets:precompile
|
35
|
+
|
36
|
+
- name: "Clean old assets, keeping current + 2 old versions + anything created within past 1 hour"
|
37
|
+
env:
|
38
|
+
RAILS_ENV: ${{ inputs.rails_env }}
|
39
|
+
SECRET_KEY_BASE_DUMMY: 1
|
40
|
+
shell: bash
|
41
|
+
run: ./bin/rake assets:clean
|
42
|
+
|
43
|
+
- name: Save cache
|
44
|
+
if: ${{ inputs.save_cache == 'true' }}
|
45
|
+
uses: actions/cache/save@v4
|
46
|
+
with:
|
47
|
+
key: ${{ inputs.rails_env }}-assets-${{ hashFiles('public/assets/.manifest.json') }}
|
48
|
+
path: |
|
49
|
+
public/assets
|
50
|
+
app/assets/builds
|
@@ -15,15 +15,11 @@ outputs:
|
|
15
15
|
runs:
|
16
16
|
using: composite
|
17
17
|
steps:
|
18
|
-
- name: Set up Ruby & Javascript
|
19
|
-
uses: ./.github/actions/setup-languages
|
20
|
-
|
21
18
|
- name: Precompile assets
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
run: bundle exec rake assets:precompile
|
19
|
+
uses: ./.github/actions/compile-assets
|
20
|
+
with:
|
21
|
+
rails_env: ${{ inputs.rails_env }}
|
22
|
+
save_cache: true
|
27
23
|
|
28
24
|
- name: Set up database
|
29
25
|
env:
|
@@ -14,12 +14,10 @@ updates:
|
|
14
14
|
directory: "/"
|
15
15
|
schedule:
|
16
16
|
interval: daily
|
17
|
-
open-pull-requests-limit: 10
|
17
|
+
open-pull-requests-limit: 10
|
18
18
|
- package-ecosystem: terraform
|
19
19
|
directories:
|
20
|
-
- "/terraform
|
21
|
-
- "/terraform/staging"
|
20
|
+
- "/terraform"
|
22
21
|
schedule:
|
23
22
|
interval: weekly
|
24
23
|
open-pull-requests-limit: 10
|
25
|
-
<% end %>
|