Skip to content

Instantly share code, notes, and snippets.

@stephenharris
Created December 15, 2019 20:51
Show Gist options
  • Save stephenharris/ec335fc4eacf6034de6f3e8456f2021a to your computer and use it in GitHub Desktop.
Save stephenharris/ec335fc4eacf6034de6f3e8456f2021a to your computer and use it in GitHub Desktop.
Circle CI config for deploying with serverless
version: 2
jobs:
build:
docker:
- image: circleci/node:10
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: Install dependencies
command: |
# serverless-plugin-optimize/.git was causing problems for npm install
rm -rf node_modules/serverless-plugin-optimize/.git
npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-
# run tests!
- run:
name: Run tests with coverage
command: npm test --coverage
- persist_to_workspace:
root: .
paths:
- '*'
deploy:
docker:
- image: circleci/node:10
steps:
- attach_workspace:
at: .
- run:
name: Deploy application
command: |
echo -e "\nAPPLICATION_VER=${CIRCLE_SHA1:0:7}-${CIRCLE_BUILD_NUM}" >> .env.production
npm run deploy:prod
workflows:
version: 2
build-deploy:
jobs:
- build
- approval:
type: approval
requires:
- build
- deploy:
requires:
- approval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment