Last active
          June 4, 2025 20:13 
        
      - 
      
- 
        Save stevenharman/98576bf49b050b9e59fb26626b7cceff to your computer and use it in GitHub Desktop. 
Revisions
- 
        stevenharman revised this gist May 30, 2020 . 2 changed files with 4 additions and 8 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,10 @@ # # Usage: bin/heroku_deploy RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[0;33m' NO_COLOR='\033[0m' set -euo pipefail This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +0,0 @@ 
- 
        stevenharman revised this gist Jun 27, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,8 +6,8 @@ }, "stack": "heroku-16", "formation": [ { "process": "web", "quantity": 1 }, { "process": "worker", "quantity": 1 } ], "addons": [ "heroku-postgresql:hobby-dev" 
- 
        stevenharman renamed this gist Nov 16, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewingFile renamed without changes.
- 
        stevenharman revised this gist Nov 16, 2017 . No changes.There are no files selected for viewing
- 
        stevenharman revised this gist Nov 15, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,10 +14,10 @@ if [ -z "$schema_version" ]; then fi if [ "$schema_version" -eq "0" ]; then printf "\n⏳${YELLOW} [Release Phase]: Loading the database schema.${NO_COLOR}\n" bin/rails db:schema:load else printf "\n⏳${YELLOW} [Release Phase]: Running database migrations.${NO_COLOR}\n" bin/rails db:migrate fi 
- 
        stevenharman revised this gist Nov 15, 2017 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,16 +9,16 @@ set -euo pipefail schema_version=$(bin/rails db:version | { grep "^Current version: [0-9]\\+$" || true; } | tr -s ' ' | cut -d ' ' -f3) if [ -z "$schema_version" ]; then printf "💀${RED} [Release Phase]: Database schema version could not be determined. Does the database exist?${NO_COLOR}\n" exit 1 fi if [ "$schema_version" -eq "0" ]; then printf "\n⚠️${YELLOW} [Release Phase]: Loading the database schema.${NO_COLOR}\n" bin/rails db:schema:load else printf "\n⚠️${YELLOW} [Release Phase]: Running database migrations.${NO_COLOR}\n" bin/rails db:migrate fi printf "\n🎉${GREEN} [Release Phase]: Database is up to date.${NO_COLOR}\n" 
- 
        stevenharman created this gist Nov 15, 2017 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ # Heroku Release Phase + Review Apps + Rails This is a simplified, but fairly thorough, set of scripts and configuration to enable [Heroku Release Phase](https://devcenter.heroku.com/articles/release-phase) for Rails apps. Further, this particular set up plays nicely with [Heroku Review Apps](https://devcenter.heroku.com/articles/github-integration-review-apps) in that the `release` phase script will: 1. Fail, loudly, if the DB does not yet exist. 1. Load the DB schema if the current schema version (as determined by `bin/rails db:version`) is `0`. 1. Run DB migrations otherwise. For a "normal" app that usually means it will run the DB migrations. For a Review App, on the first deploy the `release` phase will `bin/rails db:schema:load`. And then the `postdeploy` script will seed data. During subsequent deploys to the Review App, the `release` phase will `bin/rails db:migrate`. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ web: bundle exec puma -C ./config/puma.rb worker: DB_POOL_SIZE=${WORKER_CONCURRENCY:-20} bundle exec sidekiq -c ${WORKER_CONCURRENCY:-20} -t ${WORKER_TIMEOUT:-25} -q default,1 -q mailers,1 # === Heroku Release Phase, ignored by `heroku local`. See: https://devcenter.heroku.com/articles/release-phase release: bin/heroku_release This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ { "name": "your-app-name", "description": "Configuration for per-Pull-Request Reviews Apps on Heroku.", "scripts": { "postdeploy": "LOG_LEVEL=INFO bin/rake review_app:seed" }, "stack": "heroku-16", "formation": [ { "process": "web", "quantity": 1}, { "process": "worker", "quantity": 1} ], "addons": [ "heroku-postgresql:hobby-dev" ], "buildpacks": [ { "url": "heroku/ruby" } ], "env": { "Lots of other Env Vars...": "as you need", "HEROKU_APP_NAME": { "required": true }, "HEROKU_PARENT_APP_NAME": { "required": true } } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ #!/usr/bin/env bash # # Usage: bin/heroku_deploy . ./shell_colors set -euo pipefail schema_version=$(bin/rails db:version | { grep "^Current version: [0-9]\\+$" || true; } | tr -s ' ' | cut -d ' ' -f3) if [ -z "$schema_version" ]; then printf "💀${RED} Database schema version could not be determined. Does the database exist?${NO_COLOR}\n" exit 1 fi if [ "$schema_version" -eq "0" ]; then printf "\n⚠️${YELLOW} Loading the database schema.${NO_COLOR}\n" bin/rails db:schema:load else printf "\n⚠️${YELLOW} Running database migrations.${NO_COLOR}\n" bin/rails db:migrate fi printf "\n🎉${GREEN} Release Phase: database is up to date.${NO_COLOR}\n" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ #!/usr/bin/env bash RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[0;33m' NO_COLOR='\033[0m' CLEAR_LINE='\r\033[K' This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ # frozen_string_literal: true namespace :review_app do desc 'Ensure environment is one we shish to spread seed in' task :ensure_review_app do abort 'This is not a Heroku Review App' unless review_app? end desc 'Seeds a review app with a subset of realistic-looking data' task :seed, [] => %w[ ensure_review_app environment db:seed seed:administrator seed:widgets ] do Rails.logger.tagged('Seed App') { |l| l.info("Finished seeding new Review App: #{ENV['HEROKU_APP_NAME']}") } end def review_app? !!ENV['HEROKU_PARENT_APP_NAME'] end end