1
+ #! /usr/bin/bash
2
+
3
+ # protect ourselves from bash nonsense
4
+ set -o errexit # fail the script if any command fails
5
+ set -o pipefail # fail if a pipeline fails
6
+ set -o nounset # fail if we use an unset variable
7
+
1
8
export RAZZLE_PUBLIC_DIR=/var/app/current/build/public
2
9
export PORT=8081
3
10
export RAZZLE_AMPLITUDE_KEY=` eb printenv | grep -Eo " RAZZLE_AMPLITUDE_KEY.=.(.*)" | sed -E " s/RAZZLE_AMPLITUDE_KEY.=.//" `
4
11
export RAZZLE_CDN_ROOT=https://d24gftfomm9wsp.cloudfront.net
5
12
6
- git branch | grep " * master" > /dev/null
7
- if [ $? -ne 0 ]
8
- then
9
- echo " Branch is not master, aborting deploy" >&2
13
+ function fail() {
14
+ echo " ${1} " >&2
10
15
exit
11
- fi
16
+ }
12
17
13
- git status | grep " nothing to commit" > /dev/null
14
- if [ $? -ne 0 ]
15
- then
16
- echo " Branch is dirty, aborting deploy" >&2
17
- exit
18
- fi
18
+ function cleanup() {
19
+ echo " running cleanup..."
20
+ # move the real .gitignore back
21
+ mv .gitignore.bak .gitignore 2> /dev/null || echo " never created gitignore.bak"
22
+ git reset
23
+ }
24
+
25
+ trap cleanup EXIT
26
+
27
+ # make sure we're on a clean master
28
+ git branch | grep " * master" > /dev/null || fail " Branch is not master, aborting deploy"
29
+ git status | grep " nothing to commit" > /dev/null || fail " Branch is dirty, aborting deploy"
19
30
20
31
# take build out of .gitignore for deploy (long story)
21
32
git checkout .gitignore
@@ -26,8 +37,4 @@ mv .gitignore.deploy .gitignore
26
37
npm run build
27
38
git add build
28
39
aws s3 sync --size-only --acl public-read build/public/ s3://spaceship-earth/public/
29
- eb deploy Spaceship-$1 --staged
30
-
31
- # move the real .gitignore back
32
- mv .gitignore.bak .gitignore
33
- git reset
40
+ eb deploy Spaceship-$1 --staged || echo " either EB failed or you CTRL-Ced it!"
0 commit comments