|
3 | 3 | # The script should immediately exit if any command in the script fails. |
4 | 4 | set -e |
5 | 5 |
|
| 6 | +# This script deploys the Cloud Functions of the screenshot tool to Firebase. |
| 7 | +# Before deploying, the script installs all dependencies of the functions. |
| 8 | + |
| 9 | +# Go to the project root directory |
| 10 | +cd $(dirname ${0})/../.. |
| 11 | + |
6 | 12 | if [ -z ${MATERIAL2_SCREENSHOT_FIREBASE_DEPLOY_TOKEN} ]; then |
7 | 13 | echo "Error: No access token for firebase specified." \ |
8 | 14 | "Please set the environment variable 'MATERIAL2_SCREENSHOT_FIREBASE_DEPLOY_TOKEN'." |
9 | 15 | exit 1 |
10 | 16 | fi |
11 | 17 |
|
12 | | -# Go to the project root directory |
13 | | -cd $(dirname ${0})/../.. |
| 18 | +# Path to the screenshot tool in the project. |
| 19 | +screenshotToolFolder="tools/dashboard" |
14 | 20 |
|
15 | | -# Paths to the screenshot-test directory that also contains the function directory. |
16 | | -screenshotTestFolder=tools/screenshot-test |
| 21 | +# Path to the firebase binary of the root package.json |
| 22 | +firebaseBin=$(npm bin)/firebase |
17 | 23 |
|
18 | 24 | # Go to the screenshot-test folder because otherwise Firebase tries to deploy the wrong project. |
19 | | -cd ${screenshotTestFolder} |
| 25 | +cd ${screenshotToolFolder} |
20 | 26 |
|
21 | 27 | # Install node modules for the screenshot functions. Firebase CLI needs to execute the functions |
22 | | -# before it can collect all functions and deploy them. |
| 28 | +# to collect all function names before it can deploy them. |
23 | 29 | (cd functions; npm install) |
24 | 30 |
|
25 | 31 | # Deploy the screenshot functions to Firebase |
26 | | -$(npm bin)/firebase deploy --only functions --token ${MATERIAL2_SCREENSHOT_FIREBASE_DEPLOY_TOKEN} \ |
27 | | - --project material2-screenshots |
| 32 | +${firebaseBin} deploy --only functions --token ${MATERIAL2_SCREENSHOT_FIREBASE_DEPLOY_TOKEN} \ |
| 33 | + --non-interactive --project material2-screenshots |
0 commit comments