Skip to content

Instantly share code, notes, and snippets.

@pamo
Created July 15, 2017 03:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pamo/6e16ebc7f6c0c7756653da22ed7cbbaa to your computer and use it in GitHub Desktop.
Save pamo/6e16ebc7f6c0c7756653da22ed7cbbaa to your computer and use it in GitHub Desktop.
CircleCI 2.0 Workflows
defaults: &defaults
working_directory: ~/app
docker:
- image: circleci/node:8.1.4-browsers
version: 2
jobs:
build:
<<: *defaults
steps:
- checkout
- run:
name: set-user-permissions
command: sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: update-npm
command: yarn global add npm@^5.2
- run:
name: install-npm-dependencies
command: npm install --silent
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: gulp-build
command: npx gulp build
test:
<<: *defaults
steps:
- checkout
- run:
name: set-user-permissions
command: sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: update-npm
command: yarn global add npm@^5.2
- run:
name: install-npm-dependencies
command: npm install --silent
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: test
command: npm test
deploy:
<<: *defaults
steps:
- checkout
- run:
name: set-user-permissions
command: sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: update-npm
command: yarn global add npm@^5.2
- run:
name: install-npm-dependencies
command: npm install --silent
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: deploy
command: |
DEPLOY_ENV=$(echo $CIRCLE_BRANCH | sed -e "s/^integration\///")
npx gulp deploy --env=$DEPLOY_ENV
workflows:
version: 2
build_test_or_deploy:
jobs:
- build
- test:
requires:
- build
filters:
branches:
ignore: /integration\/.*/
- deploy:
requires:
- build
filters:
branches:
only: /integration\/.*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment