So I'm fine with the source code to my files being public, but I obviously don't want my passwords/login info/etc to be public.
How can I host the repo with GitHub publicly but keep myself safe?
Web Applications Stack Exchange is a question and answer site for power users of web applications. It only takes a minute to sign up.Sign up to join this community
Generally, all config data like passwords and database info will be kept in a config file. To keep private data safe, I usually:
.gitignoreso that it is not a tracked file
Those are my thoughts ...
You have at least two ways:
I like to configure all my apps from the environment. This allows for a clean separation of code and environment - see The 12-Factor App.
In a Rails project, for example, I'll check in the
secrets.yml file with these contents (as an example):
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
domain_name: <%= ENV["DOMAIN_NAME"] %>
Then all of the configuration happens in my environment. There's also a handy gem for Rails that will load a
.env file with variables for my environment called
dot-env. This file is never checked in (but a
.env.example file is provided with placeholder values).
When the app is deployed the tools will make sure to configure the environment before deploying the code.