Pushing .gitignore files to specific remote

◇◆丶佛笑我妖孽 提交于 2019-12-02 22:43:18

It is possible to maintain a separate branch just for deployment, but it takes much discipline to maintain it properly:

  1. Add a commit to a production branch that adds the config file (git add -f to bybass your excludes).
  2. To update your production branch, merge other branches (e.g. master) into it.
    However, you must then never merge your production branch into anything else, or start branches based on any “production commit” (one whose ancestry includes your “add the keys” commit).

An easier path is to adopt Heroku’s custom of using environment variables to communicate your secret values to your instances. See the docs on Configuration and Config Vars:

heroku config:add KEY1=foobar KEY2=frobozz

Then access the values via ENV['KEY1'] and ENV['KEY2'] in your initialization code or wherever you need them. To support your non-Heroku deployments, you could either define the same environment variables or fall back to reading your existing config files if the environment variables do not exist.

The Figaro gem provides a good way to manage this issue. It basically simulates Heroku's environment variable approach locally, and makes it easy to keep your keys in sync between your development environment and Heroku.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!