forked from nassibnassar/yamz
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tyamz
executable file
·79 lines (66 loc) · 2.11 KB
/
tyamz
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
#!/usr/bin/env bash
sb=master # starting branch (master?)
me=$( basename $0 )
[[ "$1" ]] || {
cat << EOT
Usage: $me go
Helps your edit/deploy/test loop when testing directly on a "tyamz"
dev heroku instance (as opposed to testing locally). Meant to be
called from your $sb branch, it automates these steps:
- switch to deploy_keys branch
- merge latest changes from $sb into deploy_keys
- push deploy_keys to heroku "tyamz" instance
- switch back to $sb branch, ready for subsequent edits
To deploy to production, manually do steps something like this:
git checkout -q deploy_keys
cp warts/yamz/.seaice* .
git commit -a -m "key swap" # IMPORTANT! so production keys are pushed
# test keys: logout of yamz, then back in
git merge -q -m "lots of bug fixes" master
git push -q heroku_production deploy_keys:master
cp warts/tyamz/.seaice* .
git commit -a -m "re-swap" # IMPORTANT! revert to test keys in future
git checkout -q master
chmod 600 .seaice*
EOT
exit 1
}
curbranch=$( git rev-parse --abbrev-ref HEAD ) # glad google knew this
[[ "$curbranch" == "$sb" ]] || {
echo "error: current branch ($curbranch) must be $sb"
exit 1
}
set -x
git commit -a -q -m fix || {
echo "abort: problem committing latest changes to $sb"
exit 1
}
git checkout -q deploy_keys || {
echo "abort: error checking out deploy_keys"
exit 1
}
stop=$( cmp warts/tyamz/.seaice_auth .seaice_auth )
[[ "$stop" ]] && {
echo 'error: .seaice_auth appears set for production deploy;' \
'you may wish to "cp warts/tyamz/.seaice* ."'
echo "$stop"
echo "NOTE: current branch is deploy_keys"
exit 1
}
git merge -q -m "update from edited branch prior to deploy" $sb || {
echo "abort: couldn't update deploy_keys with latest $sb commits"
echo "NOTE: current branch is deploy_keys"
exit 1
}
git push -q heroku deploy_keys:$sb || {
echo "error deploying tyamz to heroku"
echo "NOTE: current branch is deploy_keys"
exit 1
}
git checkout -q $sb || {
echo "error re-checking out $sb after deploy"
echo "NOTE: current branch is deploy_keys"
exit 1
}
chmod 600 .seaice* # because git won't preserve file metadata
set +x