参考
Herokuアプリフォーク
heroku fork -a APPNAME APPNAME-staging
※アドオンも全てコピーされるため有料プランを使っている場合などは注意
git remote追加
git remote add staging git@heroku.com:APPNAME-staging.git
ステージングへ環境変更
heroku config:set RACK_ENV=staging RAILS_ENV=staging --remote staging
設定ファイルコピー
cp config/environments/production.rb config/environments/staging.rb
設定追加
- シークレットキー設定
config/secrets.yml
staging:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
- シークレットキーHeroku登録
キー作成
rake secret
----------
0304acfda4a421d8bc9761d691bf2c27ae4629d144f5eb78a228488c22d8dae737f945ac6c8f55beb563dbcf53c1a02eaedcb6b36cf7d0c5d80dce883231a5eb
----------
キー登録
heroku config:set SECRET_KEY_BASE='0304acfda4a421d8bc9761d691bf2c27ae4629d144f5eb78a228488c22d8dae737f945ac6c8f55beb563dbcf53c1a02eaedcb6b36cf7d0c5d80dce883231a5eb' --remote staging
ステージングデプロイ
- stagingブランチをリモートのmasterブランチにpush
git push staging staging:master && heroku run rake db:migrate --remote staging
ステージングサイト確認
heroku open --remote staging