docs(circleci): Set up automatic deploys to GCP for hosting viewer.ohif.org (#491)

This commit is contained in:
Erik Ziegler 2019-06-05 22:08:28 +02:00 committed by GitHub
parent a111327ff6
commit d20492ac62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 63 additions and 0 deletions

View File

@ -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

View File

@ -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",