You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
3.3 KiB
105 lines
3.3 KiB
version: 2
|
|
jobs:
|
|
build:
|
|
docker:
|
|
- image: circleci/node:dubnium-browsers
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
keys:
|
|
- npm-v1-dependencies-{{ checksum "yarn.lock" }}
|
|
- run: yarn global add node-gyp && yarn install
|
|
- save_cache:
|
|
key: npm-v1-dependencies-{{ checksum "yarn.lock" }}
|
|
paths:
|
|
- node_modules
|
|
|
|
test:
|
|
docker:
|
|
- image: circleci/node:12
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
keys:
|
|
- npm-v1-dependencies-{{ checksum "yarn.lock" }}
|
|
- run:
|
|
name: run test
|
|
command: |
|
|
yarn test
|
|
server-build:
|
|
docker:
|
|
- image: circleci/node:12
|
|
steps:
|
|
- checkout
|
|
- restore_cache:
|
|
keys:
|
|
- npm-v1-dependencies-{{ checksum "yarn.lock" }}
|
|
- run: |
|
|
yarn build
|
|
- run:
|
|
name: Copy build to workspace
|
|
command: |
|
|
cp dist/ /tmp/dist -r
|
|
- store_artifacts:
|
|
path: /tmp/dist
|
|
- persist_to_workspace:
|
|
root: /tmp
|
|
paths:
|
|
- dist
|
|
server-deploy:
|
|
docker:
|
|
- image: circleci/node:dubnium-browsers
|
|
working_directory: ~/netlify-deploy
|
|
steps:
|
|
- attach_workspace:
|
|
at: /tmp
|
|
- run:
|
|
name: install netlify and Deploy app
|
|
command: |
|
|
sudo npm install netlify-cli -g
|
|
netlify deploy --prod --auth $NETLIFY_AUTH_TOKEN --dir=/tmp/dist --site $NETLIFY_SITE_ID
|
|
|
|
docker-build-and-push:
|
|
docker:
|
|
- image: docker:17.05.0-ce-git
|
|
steps:
|
|
- checkout
|
|
- setup_remote_docker
|
|
- run:
|
|
name: Build application Docker image
|
|
command: |
|
|
docker build --cache-from=app -t app .
|
|
- deploy:
|
|
name: Publish application to docker hub
|
|
command: |
|
|
docker login -e $DOCKER_HUB_EMAIL -u $DOCKER_HUB_USER_ID -p $DOCKER_HUB_PWD
|
|
docker tag app $DOCKER_HUB_USER_ID/devops-front-final:$CIRCLE_BUILD_NUM
|
|
docker tag app $DOCKER_HUB_USER_ID/devops-front-final:1.0
|
|
docker push $DOCKER_HUB_USER_ID/devops-front-final:$CIRCLE_BUILD_NUM
|
|
docker push $DOCKER_HUB_USER_ID/devops-front-final:1.0
|
|
|
|
workflows:
|
|
version: 2
|
|
build-deploy:
|
|
jobs:
|
|
- build
|
|
- test:
|
|
requires:
|
|
- build
|
|
- server-build:
|
|
requires:
|
|
- build
|
|
- server-deploy:
|
|
requires:
|
|
- server-build
|
|
filters:
|
|
branches:
|
|
only: main
|
|
- docker-build-and-push:
|
|
requires:
|
|
- build
|
|
filters:
|
|
branches:
|
|
only: main
|
|
|
|
|