From 93d99c36453a69eebbd76f5935580f3515c69509 Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Thu, 26 Jul 2018 21:22:30 +0200 Subject: [PATCH 1/6] Heroku postdeploy is a toplevel concern + add demo data --- app.json | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/app.json b/app.json index 689bf0a84..dd3c7d6cd 100644 --- a/app.json +++ b/app.json @@ -23,21 +23,13 @@ "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" + "SMTP_SERVER": "smtp.sendgrid.net" } } }, + "scripts": { + "postdeploy": "env ERRBIT_ADMIN_EMAIL=admin@example.com ERRBIT_ADMIN_PASSWORD=demo-admin bundle exec rake errbit:bootstrap errbit:demo" + }, "addons": [ "mongolab:sandbox", "scheduler:standard", From d09d302ce5b09665ff5fe079efe9c286b8de1159 Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Sat, 28 Jul 2018 07:28:13 +0200 Subject: [PATCH 2/6] Document actual default login email --- docs/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 2192d5039..5a6f3bba0 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -24,7 +24,7 @@ In order of precedence Errbit uses:
defaults to false
ERRBIT_ADMIN_EMAIL
E-Mail address of initial admin user -
defaults to `errbit@example.com` +
defaults to `errbit@errbit.example.com`
ERRBIT_ADMIN_PASSWORD
Password of initial admin user
defaults to some random string (see output of `$ rake db:seed`) From cca4883404a2f45818ec58ffaf17f901509414b0 Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Sat, 4 Aug 2018 23:38:42 +0200 Subject: [PATCH 3/6] Seeds: use methods instead of variables Going to add a bit more complexity here --- db/seeds.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index fa16dac24..deebfed5c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,8 +5,14 @@ # 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 + ENV['ERRBIT_ADMIN_EMAIL'] || "errbit@#{Errbit::Config.host}" +end + +def admin_pass + @admin_pass ||= ENV['ERRBIT_ADMIN_PASSWORD'] || SecureRandom.urlsafe_base64(12)[0, 12] +end puts "Creating an initial admin user:" puts "-- username: #{admin_username}" if Errbit::Config.user_has_username From d4f549a3544b61823c99ca8caf2f53fa8e7e9d48 Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Sat, 4 Aug 2018 23:39:12 +0200 Subject: [PATCH 4/6] Heroku: add HEROKU_APP_NAME variable --- app.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app.json b/app.json index dd3c7d6cd..6c0e891c0 100644 --- a/app.json +++ b/app.json @@ -10,6 +10,10 @@ "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" }, @@ -22,6 +26,10 @@ "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" } From a86c1094aae8edff7754f624d23ec858caec3a57 Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Sat, 4 Aug 2018 23:43:43 +0200 Subject: [PATCH 5/6] Heroku: move seed values into seeds.rb --- app.json | 2 +- db/seeds.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app.json b/app.json index 6c0e891c0..49730eebc 100644 --- a/app.json +++ b/app.json @@ -36,7 +36,7 @@ } }, "scripts": { - "postdeploy": "env ERRBIT_ADMIN_EMAIL=admin@example.com ERRBIT_ADMIN_PASSWORD=demo-admin bundle exec rake errbit:bootstrap errbit:demo" + "postdeploy": "bundle exec rake errbit:bootstrap errbit:demo" }, "addons": [ "mongolab:sandbox", diff --git a/db/seeds.rb b/db/seeds.rb index deebfed5c..bd1c79ca1 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -7,13 +7,22 @@ admin_username = ENV['ERRBIT_ADMIN_USER'] || "errbit" 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 puts "-- email: #{admin_email}" From 3c72409df423b0b878fa784e6d0defdc6cb78fce Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Sat, 4 Aug 2018 23:43:56 +0200 Subject: [PATCH 6/6] Heroku: remove test environment settings, identical to regular settings --- app.json | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/app.json b/app.json index 49730eebc..2c97ce588 100644 --- a/app.json +++ b/app.json @@ -17,24 +17,6 @@ "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" - }, - "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" - } - } - }, "scripts": { "postdeploy": "bundle exec rake errbit:bootstrap errbit:demo" },