forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-to-firebase.sh
executable file
·51 lines (41 loc) · 1.27 KB
/
deploy-to-firebase.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
# WARNING: FIREBASE_TOKEN should NOT be printed.
set +x -eu -o pipefail
readonly deployEnv=$1
case $deployEnv in
staging)
readonly buildEnv=stage
readonly projectId=aio-staging
readonly deployedUrl=https://$projectId.firebaseapp.com/
readonly firebaseToken=$FIREBASE_TOKEN
;;
production)
readonly buildEnv=prod
readonly projectId=angular-io
readonly deployedUrl=https://angular.io/
readonly firebaseToken=$FIREBASE_TOKEN
;;
*)
echo "Unknown deployment environment ('$deployEnv'). Expected 'staging' or 'production'."
exit 1
;;
esac
# Do not deploy if the current commit is not the latest on its branch.
readonly LATEST_COMMIT=$(git ls-remote origin $TRAVIS_BRANCH | cut -c1-40)
if [ $TRAVIS_COMMIT != $LATEST_COMMIT ]; then
echo "Skipping deploy because $TRAVIS_COMMIT is not the latest commit ($LATEST_COMMIT)."
exit 0
fi
# Deploy
(
cd "`dirname $0`/.."
# Build the app
yarn build -- --env=$buildEnv
# Check payload size
yarn payload-size
# Deploy to Firebase
firebase use "$projectId" --token "$firebaseToken"
firebase deploy --message "Commit: $TRAVIS_COMMIT" --non-interactive --token "$firebaseToken"
# Run PWA-score tests
yarn test-pwa-score -- "$deployedUrl" "$MIN_PWA_SCORE"
)