Sha256: 4c3b10194fd2248dce48f7ff774931860166696734a91772c743fb39f64efecb

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

require 'uri'

Capistrano::Configuration.instance(:must_exist).load do
  $:.unshift(File.expand_path('./lib', ENV['rvm_path']))
  require "rvm/capistrano"
  set :rvm_type, :user

  role :staging, "www@staging.botandrose.com:22022"
  set :asset_paths, []

  namespace "data" do
    namespace "pull" do
      desc "pull data"
      task "default" do
        run "cd #{application} && rake db:dump && gzip -9f db/data.sql"
        transfer :down, "#{application}/db/data.sql.gz", "db/data.sql.gz"
        system "gunzip -f db/data.sql.gz && rake db:load"
      end

      desc "sync the static assets"
      task "assets" do
        uri = URI.parse("ssh://#{roles[ENV['ROLES'].to_sym].first.to_s}")
        portopt = "-e'ssh -p#{uri.port}'" if uri.port

        [asset_paths].flatten.each do |path|
          dest_path = path.dup
          dest_path.sub! %r(/[^/]+$), '/'
          system "rsync #{portopt} --delete -avz #{uri.user}@#{uri.host}:#{application}/#{path} #{dest_path}"
        end
      end
    end
  end

  after 'data:pull', 'data:pull:assets'

  desc "push app to production"
  task :deploy, :roles => :production do
    system "git push github" if `git remote` =~ /\bgithub\b/
    run "cd #{application} && git pull origin master && rake bootstrap:production"
  end

  desc "push app to staging"
  task :stage, :roles => :staging do
    branch = ENV.has_key?("BRANCH") ? ENV["BRANCH"] : "integration"
    run "cd #{application} && git fetch && git checkout -f origin/#{branch} && rake bootstrap"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bard-0.13.1 lib/bard/capistrano.rb
bard-0.13.0 lib/bard/capistrano.rb
bard-0.12.0 lib/bard/capistrano.rb