2017-05-22 23:58:32 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2017-06-29 19:32:00 +02:00
|
|
|
# The script should immediately exit if any command in the script fails.
|
|
|
|
|
set -e
|
|
|
|
|
|
2017-08-08 22:26:33 +02:00
|
|
|
# This script deploys the Screenshot Tool and their Cloud Functions to Firebase.
|
|
|
|
|
# Before deploying, the script installs all dependencies of the functions and builds the app.
|
2017-07-18 01:23:51 +02:00
|
|
|
|
|
|
|
|
# Go to the project root directory
|
|
|
|
|
cd $(dirname ${0})/../..
|
|
|
|
|
|
2017-06-10 11:16:03 +02:00
|
|
|
if [ -z ${MATERIAL2_SCREENSHOT_FIREBASE_DEPLOY_TOKEN} ]; then
|
|
|
|
|
echo "Error: No access token for firebase specified." \
|
|
|
|
|
"Please set the environment variable 'MATERIAL2_SCREENSHOT_FIREBASE_DEPLOY_TOKEN'."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2017-07-18 01:23:51 +02:00
|
|
|
# Path to the screenshot tool in the project.
|
2017-08-04 23:03:08 +02:00
|
|
|
screenshotToolFolder="tools/screenshot-test"
|
2017-05-22 23:58:32 +02:00
|
|
|
|
2017-07-18 01:23:51 +02:00
|
|
|
# Path to the firebase binary of the root package.json
|
|
|
|
|
firebaseBin=$(npm bin)/firebase
|
2017-05-22 23:58:32 +02:00
|
|
|
|
2017-06-10 11:16:03 +02:00
|
|
|
# Go to the screenshot-test folder because otherwise Firebase tries to deploy the wrong project.
|
2017-07-18 01:23:51 +02:00
|
|
|
cd ${screenshotToolFolder}
|
2017-06-10 11:16:03 +02:00
|
|
|
|
2017-08-08 22:26:33 +02:00
|
|
|
# Install node_modules for the application and afterwards build the application in production.
|
|
|
|
|
(npm install; $(npm bin)/ng build --aot -prod) &
|
|
|
|
|
|
|
|
|
|
# Install node modules for screenshot-tool functions. Firebase CLI needs to execute the functions
|
2017-07-18 01:23:51 +02:00
|
|
|
# to collect all function names before it can deploy them.
|
2017-08-08 22:26:33 +02:00
|
|
|
(cd functions; npm install) &
|
|
|
|
|
|
|
|
|
|
# The screenshot application is being built asynchronously. Also the dependencies for the
|
|
|
|
|
# Cloud Functions are built asynchronously. This means that the script needs to wait for all
|
|
|
|
|
# async tasks to finish before proceeding.
|
|
|
|
|
wait
|
2017-05-22 23:58:32 +02:00
|
|
|
|
2017-08-08 22:26:33 +02:00
|
|
|
# Deploy the screenshot application and their functions to Firebase
|
2017-08-07 19:20:30 +02:00
|
|
|
${firebaseBin} deploy --token ${MATERIAL2_SCREENSHOT_FIREBASE_DEPLOY_TOKEN} --non-interactive \
|
|
|
|
|
--project material2-screenshots
|