Skip to content

Commit

Permalink
Merge pull request #1336 from errbit/chore/fix-heroku-demo
Browse files Browse the repository at this point in the history
Heroku deploy: add demo data too
  • Loading branch information
rud committed Aug 6, 2018
2 parents 98bcaec + 3c72409 commit 6c1a2dd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
30 changes: 6 additions & 24 deletions app.json
Expand Up @@ -10,33 +10,15 @@
"description": "A secret key for verifying the integrity of signed cookies.",
"generator": "secret"
},
"HEROKU_APP_NAME": {
"description": "Have Heroku export the current app name for review apps, see https://devcenter.heroku.com/articles/github-integration-review-apps#heroku_app_name-and-heroku_parent_app_name",
"required": true
},
"EMAIL_DELIVERY_METHOD": "smtp",
"SMTP_SERVER": "smtp.sendgrid.net"
},
"environments": {
"test": {
"env": {
"ERRBIT_ENFORCE_SSL": "true",
"GEMFILE_RUBY_VERSION": "2.3.3",
"SECRET_KEY_BASE": {
"description": "A secret key for verifying the integrity of signed cookies.",
"generator": "secret"
},
"EMAIL_DELIVERY_METHOD": "smtp",
"SMTP_SERVER": "smtp.sendgrid.net",
"ERRBIT_ADMIN_EMAIL": {
"description": "Set the demo admin login for ease of PR review",
"value":"admin@example.com"
},
"ERRBIT_ADMIN_PASSWORD": {
"description": "Set the demo admin password for ease of PR review",
"value": "demo-admin"
}
},
"scripts": {
"postdeploy": "bundle exec rake errbit:bootstrap"
}
}
"scripts": {
"postdeploy": "bundle exec rake errbit:bootstrap errbit:demo"
},
"addons": [
"mongolab:sandbox",
Expand Down
19 changes: 17 additions & 2 deletions db/seeds.rb
Expand Up @@ -5,8 +5,23 @@

# Create an initial Admin User
admin_username = ENV['ERRBIT_ADMIN_USER'] || "errbit"
admin_email = ENV['ERRBIT_ADMIN_EMAIL'] || "errbit@#{Errbit::Config.host}"
admin_pass = ENV['ERRBIT_ADMIN_PASSWORD'] || SecureRandom.urlsafe_base64(12)[0, 12]

def admin_email
return 'admin@example.com' if heroku_pr_review_app?

ENV['ERRBIT_ADMIN_EMAIL'] || "errbit@#{Errbit::Config.host}"
end

def admin_pass
return 'demo-admin' if heroku_pr_review_app?

@admin_pass ||= ENV['ERRBIT_ADMIN_PASSWORD'] || SecureRandom.urlsafe_base64(12)[0, 12]
end

def heroku_pr_review_app?
app_name = ENV.fetch("HEROKU_APP_NAME", "")
app_name.include?("errbit-deploy-pr-")
end

puts "Creating an initial admin user:"
puts "-- username: #{admin_username}" if Errbit::Config.user_has_username
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Expand Up @@ -24,7 +24,7 @@ In order of precedence Errbit uses:
<dd>defaults to false
<dt>ERRBIT_ADMIN_EMAIL
<dd>E-Mail address of initial admin user
<dd>defaults to `errbit@example.com`
<dd>defaults to `errbit@errbit.example.com`
<dt>ERRBIT_ADMIN_PASSWORD
<dd>Password of initial admin user
<dd>defaults to some random string (see output of `$ rake db:seed`)
Expand Down

0 comments on commit 6c1a2dd

Please sign in to comment.