Last active
May 22, 2018 02:36
-
-
Save Rutulpatel7077/c6565cb75c9e8b43f44812fdc0cab5d7 to your computer and use it in GitHub Desktop.
Config file for circleCi and AWS CI & CD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2 | |
jobs: | |
# The build job | |
build: | |
working_directory: ~/project | |
docker: | |
- image: circleci/node:6.10-browsers | |
steps: | |
# Checkout the code from the branch into the working_directory | |
- checkout | |
# Log the current branch | |
- run: | |
name: Show current branch | |
command: echo ${CIRCLE_BRANCH} | |
# Restore local dependencies from cache | |
- restore_cache: | |
keys: | |
- v1-dependencies-{{ checksum "package.json" }} | |
- v1-dependencies- | |
# Install project dependencies | |
- run: | |
name: Install local dependencies | |
command: npm install | |
# Build project | |
- run: | |
name: Build for production | |
command: npm run build | |
# Cache local dependencies if they don't exist | |
- save_cache: | |
key: v1-dependencies-{{ checksum "package.json" }} | |
paths: | |
- node_modules | |
# Test the source code | |
- run: | |
name: Run Tests | |
command: npm run test | |
# Cache the build folders for the deploy job | |
- save_cache: | |
key: v1-dist-{{ .Environment.CIRCLE_BRANCH }}-{{ .Environment.CIRCLE_SHA1 }} | |
paths: | |
- dist | |
# The deploy job | |
deploy: | |
working_directory: ~/project | |
docker: | |
- image: circleci/node:6.10-browsers | |
steps: | |
- checkout | |
# build folder that needs to be deployed | |
- restore_cache: | |
key: v1-dist-{{ .Environment.CIRCLE_BRANCH }}-{{ .Environment.CIRCLE_SHA1 }} | |
# Add the dist folder in github repo | |
- run: | |
name: Commit folder | |
command: | | |
git config credential.helper 'cache --timeout=120' | |
git config --global user.email "[email protected]" | |
git config --global user.name "Rutul Patel" | |
git add . | |
git commit -m "added dist folder from cache for the deployment" | |
# Install AWS cli | |
- run: | |
name: Install aws cli and python-pip | |
working_directory: / | |
command: | | |
sudo apt-get -y -qq update | |
sudo apt-get install python-pip python-dev build-essential | |
sudo pip install awsebcli --upgrade | |
# Deploy to the Elastic Beanstalk corresponding to the current branch | |
- run: | |
name: Deploy on AWS EB | |
command: | | |
eb deploy --timeout 60 | |
workflows: | |
version: 2 | |
# The build and deploy workflow | |
build_and_deploy: | |
jobs: | |
- build | |
# The deploy job will only run on the filtered branches and | |
# require the build job to be successful before it starts | |
- deploy: | |
requires: | |
- build | |
filters: | |
branches: | |
only: | |
- dev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment