diff --git a/scripts/deploy/deploy-screenshot-functions.sh b/scripts/deploy/deploy-screenshot-functions.sh index 8e2f490c8ed..3e29490bbf1 100755 --- a/scripts/deploy/deploy-screenshot-functions.sh +++ b/scripts/deploy/deploy-screenshot-functions.sh @@ -3,18 +3,25 @@ # The script should immediately exit if any command in the script fails. set -e -# Go to the project root directory -cd $(dirname ${0})/../.. - -# Install node modules for screenshot functions. Firebase CLI needs to execute the functions -# before it can collect all functions and deploy them. -(cd tools/screenshot-test/functions; npm install) - -if [ -z ${MATERIAL2_SCREENSHOT_ACCESS_TOKEN} ]; then +if [ -z ${MATERIAL2_SCREENSHOT_FIREBASE_DEPLOY_TOKEN} ]; then echo "Error: No access token for firebase specified." \ - "Please set the environment variable 'MATERIAL2_SCREENSHOT_ACCESS_TOKEN'." + "Please set the environment variable 'MATERIAL2_SCREENSHOT_FIREBASE_DEPLOY_TOKEN'." exit 1 fi +# Go to the project root directory +cd $(dirname ${0})/../.. + +# Paths to the screenshot-test directory that also contains the function directory. +screenshotTestFolder=tools/screenshot-test + +# Go to the screenshot-test folder because otherwise Firebase tries to deploy the wrong project. +cd ${screenshotTestFolder} + +# Install node modules for the screenshot functions. Firebase CLI needs to execute the functions +# before it can collect all functions and deploy them. +(cd functions; npm install) + # Deploy the screenshot functions to Firebase -$(npm bin)/firebase deploy --only functions --token ${MATERIAL2_SCREENSHOT_ACCESS_TOKEN} +$(npm bin)/firebase deploy --only functions --token ${MATERIAL2_SCREENSHOT_FIREBASE_DEPLOY_TOKEN} \ + --project material2-screenshots diff --git a/tools/gulp/util/firebase.ts b/tools/gulp/util/firebase.ts index 3675aee4ad1..586e1d5ba8f 100644 --- a/tools/gulp/util/firebase.ts +++ b/tools/gulp/util/firebase.ts @@ -38,7 +38,7 @@ export function openScreenshotsBucket() { projectId: 'material2-screenshots', credentials: { client_email: 'firebase-adminsdk-t4209@material2-screenshots.iam.gserviceaccount.com', - private_key: decode(process.env['MATERIAL2_SCREENSHOT_FIREBASE_KEY']) + private_key: decode(process.env['MATERIAL2_SCREENSHOT_FIREBASE_SERVICE_KEY']) }, });