Skip to content

Instantly share code, notes, and snippets.

@zzak
Forked from pamo/config.yml
Last active August 24, 2018 23:59
Show Gist options
  • Save zzak/e3ebede4b3ef6d45c262a07461d6c594 to your computer and use it in GitHub Desktop.
Save zzak/e3ebede4b3ef6d45c262a07461d6c594 to your computer and use it in GitHub Desktop.
CircleCI 2.0 Workflows
references:
defaults: &defaults
working_directory: ~/app
docker:
- image: circleci/node:8.1.4-browsers
npm_permissions: &npm_permissions
run:
name: set-user-permissions
command: sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
npm_restore_cache: &npm_restore_cache
restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
npm_update: &npm_update
run:
name: update-npm
command: yarn global add npm@^5.2
npm_install: &npm_install
run:
name: install-npm-dependencies
command: npm install --silent
npm_save_cache: &npm_save_cache
save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
version: 2
jobs:
build:
<<: *defaults
steps:
- checkout
- << : *npm_permissions
- << : *npm_restore_cache
- << : *npm_update
- << : *npm_install
- << : *npm_save_cache
- run:
name: gulp-build
command: npx gulp build
test:
<<: *defaults
steps:
- checkout
- << : *npm_permissions
- << : *npm_restore_cache
- << : *npm_update
- << : *npm_install
- << : *npm_save_cache
- run:
name: test
command: npm test
deploy:
<<: *defaults
steps:
- checkout
- << : *npm_permissions
- << : *npm_restore_cache
- << : *npm_update
- << : *npm_install
- << : *npm_save_cache
- 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