Skip to content

Instantly share code, notes, and snippets.

@sathiyaseelan
Created August 2, 2018 10:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sathiyaseelan/51278a94b9b802ce23a774dafaad48cf to your computer and use it in GitHub Desktop.
Save sathiyaseelan/51278a94b9b802ce23a774dafaad48cf to your computer and use it in GitHub Desktop.
Sample Circle ci config to deploy a node application in heroku and run integration tests before and after release using cypress
# .circleci/config.yml
version: 2
defaults: &defaults
working_directory: ~/app
docker:
# the Docker image with Cypress dependencies
- image: cypress/base:8
environment:
## this enables colors in the output
TERM: xterm
jobs:
build:
<<: *defaults
steps:
- checkout
- restore_cache:
key: v2-deps-{{ .Branch }}-{{ checksum "package-lock.json" }}
key: v2-deps-{{ .Branch }}
key: v2-deps
- run:
name: Install Dependencies
command: npm install
- save_cache:
key: v2-deps-{{ .Branch }}-{{ checksum "package-lock.json" }}
paths:
- node_modules
- ~/.npm
- ~/.cache
- run:
name: Run Tests
command: npm run ci
- store_test_results:
path: results
- store_artifacts:
path: cypress/screenshots
deploy:
<<: *defaults
steps:
- checkout
- restore_cache:
key: v2-deps-{{ .Branch }}-{{ checksum "package-lock.json" }}
key: v2-deps-{{ .Branch }}
key: v2-deps
- run:
name: Deploy Master to Heroku
command: |
git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP.git master --force
- run:
name: Run tests on Staging Server
command: npm run cy-test -- --config=baseUrl=https://$HEROKU_APP.herokuapp.com/en
- store_test_results:
path: results
- store_artifacts:
path: cypress/screenshots
workflows:
version: 2
build-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment