Skip to content

Commit

Permalink
Add Rails master key to CI tests
Browse files Browse the repository at this point in the history
The value is needed to initialise Rails during testing
  • Loading branch information
scruti committed Aug 22, 2024
1 parent fdf4f62 commit 7808986
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ jobs:
with:
build-args: |
BUILDKIT_INLINE_CACHE=1
RAILS_MASTER_KEY=${{ secrets.RAILS_MASTER_KEY }}
# Cache from builder target tagged with branch name, may be empty first time branch is pushed
# Cache from builder target tagged with main branch name, always present, maybe less recent
cache-from: |
Expand All @@ -112,6 +113,7 @@ jobs:
build-args: |
BUILDKIT_INLINE_CACHE=1
COMMIT_SHA=${{ env.COMMIT_SHA }}
RAILS_MASTER_KEY=${{ secrets.RAILS_MASTER_KEY }}
# Cache from builder target built above, always present
# Cache from production target tagged with branch name, may be empty first time branch is pushed
# Cache from production target tagged with main branch name, always present, maybe less recent
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ jobs:
runs-on: ubuntu-20.04

env:
RAILS_ENV: test
DATABASE_URL: postgis://postgres:postgres@localhost:5432/tvs_test
RAILS_ENV: test
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}

services:
postgres:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ jobs:
params: '--exclude-pattern "spec/{system}/*_spec.rb, spec/system/{jobseekers,publishers,support_users,other}/*_spec.rb"'

env:
RAILS_ENV: test
DATABASE_URL: postgis://postgres:postgres@localhost:5432/tvs_test
RAILS_ENV: test
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}

services:
postgres:
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ COPY . .
# configuring it using the ENV variables we provide in storage.yml. However, at this point, these ENV vars have not been loaded,
# causing the error. Below we define two throaway ENV vars to prevent the error from being thrown. These are then later overwritten,
# when all of the ENV vars are loaded.
ARG RAILS_MASTER_KEY

Check warning on line 35 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build docker image

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "RAILS_MASTER_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 35 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build docker image

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "RAILS_MASTER_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

ENV DOCUMENTS_S3_BUCKET=throwaway_value
ENV SCHOOLS_IMAGES_LOGOS_S3_BUCKET=throwaway_value
ENV RAILS_MASTER_KEY=$RAILS_MASTER_KEY

Check warning on line 39 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build docker image

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "RAILS_MASTER_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 39 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build docker image

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "RAILS_MASTER_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

RUN RAILS_ENV=production SECRET_KEY_BASE=required-to-run-but-not-used RAILS_SERVE_STATIC_FILES=1 bundle exec rake assets:precompile

Expand Down

0 comments on commit 7808986

Please sign in to comment.