Skip to content

Commit

Permalink
Finish documenting Continous deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
gugzkumar committed Jan 1, 2020
1 parent 6f85aa2 commit d58c85e
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion docs/setting-up-ci-cd.md
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
# Setting Up CI/CD For A Remote Environment
# Setting Up Continuous Deployment Via CircleCI

Continuous Deployment automates the updating of new code in our Api and UI so that we can focus on building features rather than how t launch them. CircleCI is easy to use, has a free tier, and takes away the hassle of have to set up infrastructure for it.

# STEP 1: Connect CircleCI to your repo

1. Login to CircleCI using your github account
1. Under add projects set up this repo

# STEP 2: Create the ENVIRONMENT variable out of your remote.env

1. In [Setting Up And Launching The App On AWS](/docs/setting-up-remote.md) you create an `remote.env` file for code deploys
1. From the .utils folder run `node main.js create-infra-env` generate-base64-env. This will encode all contents of the `.env` file as base64 and spit it out.
1. The way we do continuous deployment is by mapping a branch in your repo to environment variable that has the contents of `remote.env` (base 64 encoded). Outbox the following deployment strategies are provided. If you want change the branch name, environment variable name, or add a new strategy follow **STEP 3**.
| Branch | CircleCI Environment Variable |
| ------ | ----------------------------- |
| master | PROD_ENV_FILE |
| develop | DEV_ENV_FILE |
| staging | STAGING_ENV_FILE |
| demo | DEMO_ENV_FILE |
1. Copy the output of the cli command, and set it as the desired Environment Variable.


# STEP 3: Update .circleci/config.yml if needed (Optional)

If you want to add more environments than supported out of the the box, modify the `load-env` command:

```yaml
load-env:
steps:
- run: # Extract environment variable as remote.env file
name: "Load remote.env file from ENVIRONMENT variables"
command: |
if [ "${CIRCLE_BRANCH}" = "master" ]; then
echo $PROD_ENV_FILE | base64 -d > remote.env
elif [ "${CIRCLE_BRANCH}" = "develop" ]; then
echo $DEV_ENV_FILE | base64 -d > remote.env
elif [ "${CIRCLE_BRANCH}" = "staging" ]; then
echo $STAGING_ENV_FILE | base64 -d > remote.env
elif [ "${CIRCLE_BRANCH}" = "demo" ]; then
echo $DEMO_ENV_FILE | base64 -d > remote.env
else
exit 1
fi
```
#

0 comments on commit d58c85e

Please sign in to comment.