Manage .env files for various GitHub projects.
You'll need an access token as described in this GitHub Help article.
1. Download setenv.sh (bash file) and place it in /usr/local/bin/setenv as an executable file:
$ cd <FILE-LOCATION>
$ chmod +x ./setenv.sh
$ mv ./setenv.sh /usr/local/bin/setenv- Edit
.bashrcto include your "env" repository (make it private!) and your token:
export ENV_REPO=<USERNAME>/<ENV-REPO>
export ENV_TOKEN=ghp_v4v78d73f9a03a694f1ca8f3488911ec2ec3For every project, create its .env file for a GitHub repository as user/repo.
For example:
- For the GitHub project
someprojfor usersomeuser, create a file namedsomeuser/someproj. - For the GitHub project
yourprojfor your user (akayouruser), create a file namedyouruser/yourproj.
To fetch your project .env file, run setenv inside the project directory on your server or local machine before running your project.
For example:
$ cd yourproj
$ setenv && npm startThis will fetch the latest data github.com/yourproj/setenv-repo/yourproj/yourproj and place it in .env.
You can also explicitly use variations of your .env file by creating adding a postfix and specifing it when running setenv.
For example, to use youruser/yourproj-prod, run:
$ cd yourproj
$ setenv prod && npm startTo use youruser/yourproj-stage, run:
$ cd yourproj
$ setenv stage && npm startEtc.
To clear the working .env file, run:
$ setenv --clear