forked from hummingbird-me/kitsu-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·54 lines (45 loc) · 1.62 KB
/
deploy.sh
File metadata and controls
executable file
·54 lines (45 loc) · 1.62 KB
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
#!/bin/bash -l
# This script will update the git repository to the latest revision in the
# origin's master branch. Then it restarts sidekiq using monit and does a zero
# downtime restart of the unicorn process.
post_message () {
curl -X POST --data-urlencode 'payload={"attachments":[{
"color": "#5DBCD2",
"text": "'"$1"'",
"fallback": "'"$1"'",
"mrkdwn_in": ["text"]'"$3"'
}]'"$2"'
}' $SLACK_WEBHOOK_URL
}
if [ -z "$2" ] || [ -z "$3" ]; then
post_message 'Deploy starting...' '' ', "author_name": "'"$1"'", "author_link": "https://hummingbird.me/users/'"$1"'", "author_icon": "'"$2"'"'
else
post_message 'Deploy starting...'
fi
DIR=$(dirname "$0")
cd $DIR
# Update the git repo.
git fetch
git checkout master
git reset --hard HEAD@{upstream}
chown -R hummingbird:www-data .
# bundle install, precompile assets, migrate database
if [ $(whoami) = "hummingbird" ]
then
cd $DIR && bundle install --deployment --without test
cd $DIR && cd frontend && npm install
cd $DIR && cd frontend && bower install
cd $DIR && bundle exec rake assets:precompile EMBERCLI_COMPILE=1
cd $DIR && bundle exec rake db:migrate
else
su - hummingbird -c "cd $DIR && bundle install --deployment --without test"
su - hummingbird -c "cd $DIR && cd frontend && npm install"
su - hummingbird -c "cd $DIR && cd frontend && bower install"
su - hummingbird -c "cd $DIR && bundle exec rake assets:precompile EMBERCLI_COMPILE=1"
su - hummingbird -c "cd $DIR && bundle exec rake db:migrate"
fi
# restart sidekiq
monit restart sidekiq
# zero-downtime unicorn restart
kill -USR2 `cat tmp/pids/unicorn.pid`
post_message 'Deploy done.'