-
Notifications
You must be signed in to change notification settings - Fork 7
/
deploy.sh
executable file
·89 lines (76 loc) · 1.69 KB
/
deploy.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
# Arguments:
# -p: deploy to prod
# -s: deploy to staging
# -v <app version>: On staging, the name of the app version to upload.
set -e
PROJECT=""
IS_PROD=0
VERSION=""
while getopts "psf:v:" opt; do
case $opt in
p)
PROJECT="cubingusa-org"
IS_PROD=1
;;
s)
PROJECT="staging-cubingusa-org"
IS_PROD=0
;;
v)
VERSION="$OPTARG"
if [ "$VERSION" == "admin" ]
then
echo "You can't use -v admin. Please select another version name."
exit 1
fi
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
if [ -z "$PROJECT" ]
then
echo "Either -p (prod) or -s (staging) must be set." >&2
exit 1
fi
if [ "$IS_PROD" == "1" -a ! -z "$VERSION" ]
then
echo "You can't specify a version for the prod app." >&2
exit 1
fi
if [ "$IS_PROD" == "0" -a -z "$VERSION" ]
then
echo "You must specify a version with -v for the staging app." >&2
exit 1
fi
echo "Recompiling minified CSS."
rm -r -f app/static/css/prod
mkdir -p app/static/css/prod
external/dart-sass/sass --update app/scss:app/static/css/prod --style compressed
echo "Deploying to App Engine."
CMD="gcloud app deploy app.yaml --project $PROJECT"
if [ ! -z "$VERSION" ]
then
CMD="$CMD --version $VERSION"
fi
echo "$CMD"
$CMD
if [ ! -z "$VERSION" ]
then
URI="https://${VERSION}-dot-$PROJECT.appspot.com"
else
URI="https://$PROJECT.appspot.com"
fi
echo "Successfully uploaded to $URI."
if [ ! -z "$VERSION" ]
then
echo "Once you're done testing, please clean up by running:"
echo "gcloud app versions delete $VERSION --project $PROJECT"
fi