This repository has been archived by the owner on Mar 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
rails-post-deploy
executable file
·75 lines (66 loc) · 2.08 KB
/
rails-post-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
#
# rails-post-deploy
# For Ruby on Rails, run this in exec_extras in vhosts.pl. It migrates the db to the most
# recent version.
#
# Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
# Email: louise@mysociety.org; WWW: http://www.mysociety.org/
#
# $Id: $
#
set -e
#set -x # debug
APP_DIR=`pwd`
# make sure that there is an app directory, so are in a rails app tree
cd app/..
# read config file in for later (STAGING_SITE)
if [ -e "config/general" ] || [ -e "config/general.yml" ]
then
. commonlib/shlib/deployfns
read_conf config/general
else
OPTION_DOMAIN=127.0.0.1:3000
OPTION_STAGING_SITE=1
fi
# Force appropriate environment (via a hack in config/boot.rb which needs
# applying to your rails app, see foi/config/boot.rb)
if [ ! -e "config/rails_env.rb" ]
then
cat <<END
*****************************************************************
WARNING: About to make config/rails_env.rb which, via special
code in config/boot.rb, forces the Rails environment to be a
particular one - this is used for the mySociety deployment
system. You don't want it for local development, because it will
not work in a confusing way you try and use two environments
(e.g. development and test) in the same working directory.
*****************************************************************
END
fi
if [ "$OPTION_STAGING_SITE" = "0" ]
then
echo "ENV['RAILS_ENV'] = 'production'" > config/rails_env.rb
elif [[ "$OPTION_DOMAIN" == *"test"* ]]
then
echo "ENV['RAILS_ENV'] = 'test'" > config/rails_env.rb
else
echo "ENV['RAILS_ENV'] = 'development'" > config/rails_env.rb
fi
bundle_install_options=""
if [ "$OPTION_STAGING_SITE" = "0" ]
then
bundle_install_options="--deployment"
fi
if [ "$OPTION_STAGING_SITE" = "1" ]
then
bundle_install_options="--path vendor/bundle"
fi
bundle install $bundle_install_options
# upgrade database
bundle exec rake db:migrate #--trace
# redeploy any cached assets
bundle exec rake cached_assets:minify
bundle exec rake cached_assets:regenerate
# reload the guides, in case they have changed
bundle exec rake guides:add_static_guides