Skip to content

Instantly share code, notes, and snippets.

@chrisbraddock
Last active July 4, 2019 14:40
Show Gist options
  • Save chrisbraddock/26dcc13cdd62491aa8fc9928fe10f9f8 to your computer and use it in GitHub Desktop.
Save chrisbraddock/26dcc13cdd62491aa8fc9928fe10f9f8 to your computer and use it in GitHub Desktop.
Firebase, CircleCi - lint, test, build, deploy; triggers on dev/master branches with develop/production contexts, respectively
version: 2.1
jobs:
build-deploy: &build-deploy
docker:
- image: circleci/node:10.15.1-browsers
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v-{{ .Branch }}-{{ .Environment.CACHE_VERSION }}-dependencies-{{ checksum "yarn.lock" }}
# 'If you need reproducible dependencies, which is usually the case with the continuous integration systems,
# you should pass --frozen-lockfile flag': https://yarnpkg.com/lang/en/docs/cli/install/
- run:
name: 'install dependencies'
command: yarn install --frozen-lockfile --ignore-optional --non-interactive
- run:
name: 'lint'
command: yarn lint
- run:
name: 'test'
command: yarn test:unit:ci --runInBand --reporters=default --reporters=jest-junit && yarn test:e2e:ci
environment:
JEST_JUNIT_OUTPUT: tests/unit/reports/unit-test-results.xml
- store_test_results:
path: tests/unit/reports
- store_test_results:
path: tests/e2e/reports
- store_artifacts:
path: tests/e2e/screenshots
destination: e2e-test-screenshots
- run:
name: 'build'
command: yarn build
- save_cache:
paths:
- node_modules
key: v-{{ .Branch }}-{{ .Environment.CACHE_VERSION }}-dependencies-{{ checksum "yarn.lock" }}
- run:
name: 'Firebase deploy'
command: |
if [ "${SKIP_DEPLOY}" != "true" ]; then
./node_modules/.bin/firebase deploy --project $FIREBASE_PROJECT --token=$FIREBASE_TOKEN
else
echo "*** skipping deploy ***"
fi
build-deploy-dev:
<<: *build-deploy
build-deploy-prod:
<<: *build-deploy
workflows:
build-deploy:
jobs:
- build-deploy-dev:
filters:
branches:
only: dev
context: develop
- build-deploy-prod:
filters:
branches:
only: master
context: production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment