Skip to content

Instantly share code, notes, and snippets.

@iannbing
Last active April 19, 2019 14:00
Show Gist options
  • Save iannbing/16acdda8e337a3bb96e92b4997c1dc50 to your computer and use it in GitHub Desktop.
Save iannbing/16acdda8e337a3bb96e92b4997c1dc50 to your computer and use it in GitHub Desktop.
Minimal CircleCI config example
version: 2.1
commands:
install:
description: 'Install packages'
steps:
- checkout
- run:
name: 'Update NPM'
command: 'sudo npm install -g npm@latest'
- restore_cache:
keys:
- dependency-cache-{{ checksum "package.json" }}
- run:
name: 'Install NPM'
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- node_modules
run_tests:
description: 'Run tests'
steps:
- run:
name: 'Run tests'
command: npm run test:ci
environment:
JEST_JUNIT_OUTPUT: 'reports/junit/js-test-results.xml'
- store_test_results:
path: reports/junit
- store_artifacts:
path: reports/junit
build:
description: 'Build the bundle'
parameters:
environment:
type: string
default: 'dev'
steps:
- run:
name: 'Build'
command: npm run build:<< parameters.environment >>
bump_beta_version:
description: 'Bump version to beta'
steps:
- run:
name: 'Bump rc version'
command: npm run add-version-suffix
publish:
description: 'Publish to npmjs'
parameters:
environment:
type: string
default: 'dev'
steps:
- run:
name: 'Authenticate with registry'
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
- run:
name: 'Publish package'
command: npm run publish:<< parameters.environment >>
build_story:
description: 'Build the story'
steps:
- run:
name: 'build storybook'
command: npm run build-storybook
jobs:
build:
docker:
- image: circleci/node:10.15
working_directory: ~/react-simple-tree-menu
steps:
- install
- run_tests
- build_story
- build:
environment: 'dev'
- build:
environment: 'prod'
release_rc:
docker:
- image: circleci/node:10.15
working_directory: ~/react-simple-tree-menu
steps:
- install
- run_tests
- build_story
- bump_beta_version
- build:
environment: 'dev'
- publish:
environment: 'dev'
release:
docker:
- image: circleci/node:10.15
working_directory: ~/react-simple-tree-menu
steps:
- install
- run_tests
- build_story
- build:
environment: 'prod'
- publish:
environment: 'prod'
workflows:
version: 2.1
build:
jobs:
- build:
filters:
branches:
ignore:
- gh-pages
- master
release:
jobs:
- release_rc:
filters:
branches:
only: development
- release:
filters:
branches:
only: master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment