Browse Source

🔧 refactor config file

main
verzelea 6 years ago
parent
commit
d4f7ed0db3
  1. 106
      .circleci/config.yml

106
.circleci/config.yml

@ -1,44 +1,74 @@
# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1
orbs:
# The Node.js orb contains a set of prepackaged CircleCI configuration you can utilize
# Orbs reduce the amount of configuration required for common tasks.
# See the orb documentation here: https://circleci.com/developer/orbs/orb/circleci/node
node: circleci/node@4.1
jobs:
# Below is the definition of your job to build and test your app, you can rename and customize it as you want.
build-and-test:
# These next lines define a docker executor: https://circleci.com/docs/2.0/executor-types/
# You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# A list of available CircleCI docker Convenience Images are available here: https://circleci.com/developer/images/image/cimg/node
jobs:
build:
docker:
- image: cimg/node:15.1
# Then run your tests!
# CircleCI will report the results back to your VCS provider.
- image: cimg/node:15.5.1-browsers
steps:
- checkout
- restore_cache:
keys:
- yarn-packages-{{ checksum "yarn.lock" }}--{{ .Environment.CACHE_VERSION }}
- yarn-packages
- run: yarn global add node-gyp && yarn install
- save_cache:
key: yarn-packages-{{ checksum "yarn.lock" }}--{{ .Environment.CACHE_VERSION }}
paths:
- node_modules
test:
docker:
- image: cimg/node:15.5.1-browsers
steps:
# Checkout the code as the first step.
- checkout
# Next, the node orb's install-packages step will install the dependencies from a package.json.
# The orb install-packages step will also automatically cache them for faster future runs.
- node/install-packages
# If you are using yarn instead npm, remove the line above and uncomment the two lines below.
# - node/install-packages:
# pkg-manager: yarn
- restore_cache:
keys:
- yarn-packages-{{ checksum "yarn.lock" }}--{{ .Environment.CACHE_VERSION }}
- run:
- name: Start test
- command : yarn test
build-in-prod:
docker:
- image: cimg/node:15.5.1-browsers
steps:
- checkout
- restore_cache:
keys:
- yarn-packages-{{ checksum "yarn.lock" }}--{{ .Environment.CACHE_VERSION }}
- run:
- name: Build the project
- command : yarn run build
- run:
- name: Copy build
- command: |
ls
cp build/ /tmp/build -r
- store_artifacts:
path: /tmp/build
- persist_to_workspace:
root: /tmp
paths:
- build
deploy:
docker:
- image: cimg/node:15.5.1-browsers
working_directory: ~/deploy-netlfify
steps:
- attach_workspace:
at: /tmp
- run:
name: Run tests
command: npm test
name: Deploy app
command: |
sudo npm install -g --silent netlify-cli
ls /tmp
netlify deploy --prod --auth $NETLIFY_AUTH_TOKEN --dir=/tmp/build --site $NETLIFY_SITE_ID
workflows:
# Below is the definition of your workflow.
# Inside the workflow, you provide the jobs you want to run, e.g this workflow runs the build-and-test job above.
# CircleCI will run this workflow on every commit.
# For more details on extending your workflow, see the configuration docs: https://circleci.com/docs/2.0/configuration-reference/#workflows
sample:
jobs:
- build-and-test
# For running simple node tests, you could optionally use the node/test job from the orb to replicate and replace the job above in fewer lines.
# - node/test
build_deploy:
jobs:
- build
- build-in-prod:
requires:
- build
- deploy:
context: netlify
requires:
- build
- build-in-prod
Loading…
Cancel
Save