Skip to content

Instantly share code, notes, and snippets.

@mariosanchez
Created April 22, 2020 14:23
Show Gist options
  • Select an option

  • Save mariosanchez/b01632c27ebc213f35bb20bf21f0cc01 to your computer and use it in GitHub Desktop.

Select an option

Save mariosanchez/b01632c27ebc213f35bb20bf21f0cc01 to your computer and use it in GitHub Desktop.
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2.1
executors:
builder:
docker:
- image: circleci/node:10.15.3
working_directory: ~/dir
commands:
prepare-environment:
description: 'Prepares environment, checking out code and installing dependencies'
steps:
- checkout # special step to check out source code to working directory
- run:
name: Update npm
command: 'sudo npm install -g npm@latest'
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package-lock.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: Install dependencies
command: npm install
jobs:
build:
executor: builder
steps:
- prepare-environment
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package-lock.json" }}
- run:
name: Run tests
command: npm run test:ci
- store_artifacts: # special step to save test results as as artifact
# Upload test summary for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
path: coverage
prefix: coverage
# Deploy on droplet by ssh and executing shell script
deploy:
machine:
enabled: true
steps:
- run:
name: Deploy over SSH
command: |
ssh $SSH_USER@$SSH_HOST "./deploy.sh"
performanceAudit:
executor: builder
steps:
- prepare-environment
- run:
name: Build production bundle
command: 'npm run build'
- run:
name: Audit bundle size
command: npm run analyze:bundlesize
workflows:
version: 2.1
build-and-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master
- performanceAudit:
requires:
- build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment