@36node/template-service
Version:
A service boilerplate with openapi,rest and mongodb.
89 lines (80 loc) • 2.07 kB
YAML
version: 2
defaults:
working_directory: ~/repo
docker:
- image: circleci/node:latest
jobs:
build:
<<:
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "yarn.lock" }}
- run:
name: Install Dependences
command: yarn install
- run:
name: Build Package
command: yarn build
- save_cache:
key: dependency-cache-{{ checksum "yarn.lock" }}
paths:
- ./node_modules
- persist_to_workspace:
root: ~/repo
paths:
- .
test:
<<:
steps:
- attach_workspace:
at: ~/repo
- run:
name: Eslint
command: yarn lint
- run:
name: Unit Test
command: yarn test --coverage
- run:
name: Upload Coverage
command: bash <(curl -s https://codecov.io/bash)
release:
<<:
steps:
- attach_workspace:
at: ~/repo
- setup_remote_docker
- run:
name: Setup Environment Variables
command: |
echo "export TAG=`if test $CIRCLE_TAG; then echo $CIRCLE_TAG; else echo "$CIRCLE_BRANCH"; fi`" >> $BASH_ENV
source $BASH_ENV
- run:
name: Build and Push Image
command: |
unset CI
chmod +x bin/build-docker.sh
bin/build-docker.sh $TAG $DOCKER_USER $DOCKER_PASS $DOCKER_REGISTRY
workflows:
version: 2
main:
jobs:
- build:
filters: # required since `release` has tag filters AND requires `build`
tags:
only: /.*/
- test:
requires:
- build
filters: # required since `release` has tag filters AND requires `test`
tags:
only: /.*/
- release:
context: production
requires:
- test
filters:
tags:
only: /v.*/
branches:
ignore: /.*/