forked from sudara/alonetone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy
executable file
·75 lines (62 loc) · 1.92 KB
/
deploy
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
#!/bin/bash
#
# This script requires `PermitUserEnvironment yes`
# to be set on the remote hosts /etc/ssh/sshd_config
echo "Deployanatoring teh codez!"
echo
# handle git and bundle install
ssh alonetone '
cd /data/alonetone
BUNDLE_CACHE_PATH="/home/deploy"
HOME="/home/deploy"
BUNDLE_PATH="/home/deploy/.rbenv/shims/bundle"
BUNDLE_COMMAND="sudo -u deploy RAILS_ENV=production ${BUNDLE_PATH}"
GIT_COMMAND="sudo -u deploy git"
echo "Telling sidekiq to chill on new jobs..."
sudo systemctl restart sidekiq
if [ ! "$($GIT_COMMAND diff)" == "" ]
then
echo "WARNING: local changes on server, exiting!"
exit 0
fi
$GIT_COMMAND fetch
if [ ! "$($GIT_COMMAND diff origin/master db)" == "" ]; then
RUN_MIGRATIONS=1
fi
if [ ! "$($GIT_COMMAND diff origin/master Gemfile.lock)" == "" ]
then
echo "Gemfile changed, bundle installing..."
$GIT_COMMAND reset --hard origin/master
$BUNDLE_COMMAND install --deployment
echo
else
echo "skipping bundle install, gemfile has not changed since last time."
$GIT_COMMAND reset --hard origin/master
echo
fi
if [[ $RUN_MIGRATIONS ]]; then
echo "Running migrations, hold tight..."
time $BUNDLE_COMMAND exec rake db:migrate
fi
echo "Compiling assets..."
time $BUNDLE_COMMAND exec rake assets:precompile
echo "Run puma, run!"
sudo monit restart puma_alonetone
# Actually cycle sidekiq
sudo systemctl restart sidekiq
'
bundle exec newrelic deployments
REVISION="$(git rev-parse --short HEAD)"
echo "Notifying bugsnag of revision release $REVISION"
curl https://build.bugsnag.com/ \
--header "Content-Type: application/json" \
--data '{
"apiKey": "'"$BUGSNAG_KEY"'",
"appVersion": "'"$REVISION"'",
"releaseStage": "production",
"sourceControl": {
"provider": "github",
"repository": "https://github.com/sudara/alonetone",
"revision": "'"${REVISION}"'"
}
}'