aboutsummaryrefslogtreecommitdiffstats
path: root/config/deploy/secret_token.rb
blob: dc2e19a991b5d6384567138306ec23185921f4db (plain) (blame)
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
unless Capistrano::Configuration.respond_to?(:instance)
  abort "This extension requires Capistrano 2"
end

Capistrano::Configuration.instance.load do

  namespace :deploy do
    namespace :token do

      desc <<-DESC
        Creates the secret token for the application.
      DESC
      task :setup, :except => { :no_release => true } do

        default_template = <<-EOF
        BetaWebApp::Application.config.secret_token = '#{`bundle exec rake secret`}'
        EOF

        run "mkdir -p #{shared_path}/config"
        put default_template, "#{shared_path}/config/secret_token.rb"
      end

      desc <<-DESC
        [internal] Updates the symlink for secret_token.rb file to the just deployed release.
      DESC
      task :symlink, :except => { :no_release => true } do
        run "ln -nfs #{shared_path}/config/secret_token.rb #{release_path}/config/secret_token.rb"
      end

    end

    after "deploy:setup",           "deploy:token:setup"   unless fetch(:skip_token_setup, false)
    after "deploy:finalize_update", "deploy:token:symlink"
  end

end