-
Notifications
You must be signed in to change notification settings - Fork 15
/
Capfile
54 lines (43 loc) · 1.79 KB
/
Capfile
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
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
set :application, "electionleaflets.org.au"
set :repository, "https://github.com/openaustralia/electionleaflets.git"
set :use_sudo, false
set :user, "deploy"
set :scm, :git
set :stage, "test" unless exists? :stage
if stage == "production"
role :web, "electionleaflets.org.au"
set :deploy_to, "/srv/www/production"
elsif stage == "test"
role :web, "electionleaflets.org.au"
set :deploy_to, "/srv/www/staging"
set :branch, "test"
set :dbname, "el-staging"
elsif stage == "development"
role :web, "electionleaflets.org.au.test"
set :deploy_to, "/srv/www/production"
set :normalize_asset_timestamps, false
end
set :dbname, "el-production" unless exists? :dbname
after 'deploy:update_code', 'deploy:symlink_configuration'
namespace :deploy do
desc "Restart doesn't do anything"
task :restart do ; end
desc "Link additional configuration"
task :symlink_configuration do
links = {
"#{release_path}/config/general.php" => "#{shared_path}/config/general.php",
"#{release_path}/data" => "#{shared_path}/data",
"#{release_path}/djangoleaflets/settings.py" => "#{shared_path}/djangoleaflets/settings.py",
"/home/deploy/.my.cnf" => "#{shared_path}/config/my.cnf",
}
# "ln -sf <a> <b>" creates a symbolic link but deletes <b> if it already exists
run links.map {|a| "ln -sf #{a.last} #{a.first}"}.join(";")
end
desc "Setup database schema - CAUTION THIS WILL DELETE DATA"
task :setup_db do
run "cat #{current_path}/schema/electionleaflets.sql | mysql #{dbname}"
run "cat #{current_path}/schema/australian_postcodes.sql | mysql #{dbname}"
end
end