Skip to content

Commit

Permalink
Seeding database only if production and if is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanMendicutti committed Aug 24, 2023
1 parent 440c6a7 commit 26a5bd4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-to-cloud-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ jobs:
env_vars: |
DATABASE_URL=postgres://%2Fcloudsql%2F${{ steps.url-encode-cloud-sql-instance.outputs.encoded-value }}/${{ env.DATABASE_NAME }}
GOOGLE_CLOUD_PROJECT=sepomex-365521
DEPLOY_NAME=${{ inputs.deploy-name }}
flags: |-
--allow-unauthenticated
--add-cloudsql-instances ${{ inputs.cloud-sql-instance }}
Expand Down
4 changes: 4 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)

if Rails.env.production? && ENV['DEPLOY_NAME'] == 'production'
Municipality.count.zero? && (bundle exec rake 'data:load')
end

0 comments on commit 26a5bd4

Please sign in to comment.