Created
December 15, 2019 20:51
-
-
Save stephenharris/ec335fc4eacf6034de6f3e8456f2021a to your computer and use it in GitHub Desktop.
Circle CI config for deploying with serverless
This file contains 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: | |
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