From d20492ac62548afa35ee81af7f487530d98bcb90 Mon Sep 17 00:00:00 2001 From: Erik Ziegler Date: Wed, 5 Jun 2019 22:08:28 +0200 Subject: [PATCH] docs(circleci): Set up automatic deploys to GCP for hosting viewer.ohif.org (#491) --- .circleci/config.yml | 62 ++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 63 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8bde358be..162d2db05 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -121,6 +121,56 @@ jobs: docker push ohif/$IMAGE_NAME:$IMAGE_VERSION_FULL docker push ohif/$IMAGE_NAME:latest fi + build_demo_site: + <<: *defaults + steps: + # Download and cache dependencies + - checkout + - restore_cache: + name: Restore Yarn Package Cache + keys: + # when lock file changes, use increasingly general patterns to restore cache + - yarn-packages-v1-{{ .Branch }}-{{ checksum "yarn.lock" }} + - yarn-packages-v1-{{ .Branch }}- + - yarn-packages-v1- + - run: + name: Install Dependencies + command: yarn install --frozen-lockfile + - save_cache: + name: Save Yarn Package Cache + paths: + - ~/.cache/yarn + key: yarn-packages-v1-{{ .Branch }}-{{ checksum "yarn.lock" }} + # Build & Test + - run: yarn build:demo:ci + # Persist :+1: + - persist_to_workspace: + root: ~/repo + paths: . + demo_site_publish: + working_directory: ~/repo + docker: + - image: google/cloud-sdk + steps: + - attach_workspace: + at: ~/repo + - setup_remote_docker: + docker_layer_caching: true + - run: + name: Deploy latest version to viewer.ohif.org + command: | + # This file will exist if a new version was published by + # our `semantic-release` command in the previous job + #if [[ ! -e tmp/updated-version.txt ]]; then + # exit 0 + #else + echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=- + gcloud --quiet config set project ${GOOGLE_PROJECT_ID} + gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE} + + gsutil -m rm gs://$GOOGLE_STORAGE_BUCKET/** + gsutil -m rsync -R build gs://$GOOGLE_STORAGE_BUCKET + #fi workflows: version: 2 @@ -153,3 +203,15 @@ workflows: requires: - build_and_test - npm_publish + - build_demo_site: + requires: + - build_and_test + filters: + branches: + only: master + - demo_site_publish: + requires: + - build_demo_site + filters: + branches: + only: master \ No newline at end of file diff --git a/package.json b/package.json index 15f389324..b2408d0bf 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "build:package:ci": "yarn run preBuild && node --max-old-space-size=4096 node_modules/rollup/bin/rollup -c", "build:web": "yarn run preBuild && react-scripts --max_old_space_size=4096 build", "build:web:ci": "yarn run preBuild && cross-env PUBLIC_URL=/demo REACT_APP_CONFIG=config/netlify.js react-scripts --max_old_space_size=4096 build && cpx 'build/**/*' docs/latest/_book/demo --verbose", + "build:demo:ci": "yarn run preBuild && cross-env PUBLIC_URL=/ REACT_APP_CONFIG=config/public_dicomweb.js react-scripts --max_old_space_size=4096 build", "lint": "eslint -c .eslintrc --fix src && prettier --single-quote --write src/**/*.{js,jsx,json,css}", "test": "jest", "test:ci": "jest --ci --runInBand --collectCoverage --reporters=default --reporters=jest-junit && codecov",