GithubHelp home page GithubHelp logo

kensodev / circle-env Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 1.0 7.27 MB

environment variables swiss army knife

Home Page: http://kensodev.github.io/circle-env

License: MIT License

Go 96.28% Shell 3.72%

circle-env's Introduction

.env swiss army knife for CircleCI (but not only)

Circle CI

What?

This is a swiss army knife CLI to work with environment variables and CircleCI.

It's designed to work "ON" the CI and also configure the CI with ENV variables.

What it does

Upload environment variables from .env to circleCI

Locally, you can work with .env and when you execute circle-env sync it will "upload" all the variabvles to CircleCI.

Replace all ENV variables in template files and rename them

For example, lets say you have a template file that looks like this

run.sh.template

/usr/bin/var/some-binary --database-name=<DB_NAME>  --password=<DB_PASSWORD>

When you execute circle-env replace it will scan the file for everything between <> and replace the value with the ENV variable.

So <DB_NAME> will be replaced with the value of $DB_NAME on the CI or local env.

The cli will write the file, dropping the .template extension, making sure you have a file you can work with. From here you can build your docker container, or anything else you want to do with the result file.

Why?

Environment variables are a good way to store "secrets" without checking them into source control.

Things like database passwords, API keys and others do not belong in your source code.

.env and the ruby project dotenv are a good way to automatically load project specific environment variable.

However, when you run your project in CI environment, those environment variables don't exist there by default.

This is where this project comes in.

Also, it's easy to create template file and only use the "real" files on CI. Say for a Docker image build

How?

  1. Download the release from the releases page.
  2. execute (refer to the usage section)

Usage

NAME:
   circle-env - Circle CI commands

USAGE:
   circle-env [global options] command [command options] [arguments...]

VERSION:
   0.0.3

COMMANDS:
   sync, p      Sync Environment Variables to CircleCI
   replace, p   Replace ENV variables in files
   help, h      Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h           show help
   --version, -v        print the version

circle-env sync

Syncs your .env file to the CircleCI project

  • project-name your CircleCI project name (eg: circleenv)
  • username Your CircleCI (and github) username (eg: KensoDev)
  • token Your CircleCI API token

Optional flag is the filename where you store your environment variables. By default it's .env in the current working directory (Which is the easiest to follow/remember)

circle-env replace

Scans your current working directory for .template files, scans the env variable in them and writes the file, replacing the content.

This will turn database.yml.template to database.yml with the variables replaces from env variables.

License

The MIT License (MIT)

Copyright (c) 2016 Avi Tzurel

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

circle-env's People

Contributors

kensodev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

dominik-k

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.