Sha256: e5c0b0eed58e6704ff774f1c692a1573445874aa8aca4e1ae2b7f2cc30ff7f5f

Contents?: true

Size: 799 Bytes

Versions: 1

Compression:

Stored size: 799 Bytes

Contents

namespace :load do
  task :defaults do
    set :safe_deploy_to_owner, nil
    set :safe_deploy_to_path, -> { fetch(:deploy_to) }
  end
end

namespace :safe_deploy_to do
  task :create do
    on roles :all do
      sudo :mkdir, '-pv', fetch(:safe_deploy_to_path)
    end
  end

  task ensure_owner: [:create] do
    on roles :all do
      unless fetch(:safe_deploy_to_owner)
        user = capture :id, '-un'
        group = capture :id, '-gn'
        set :safe_deploy_to_owner, "#{user}:#{group}"
      end
      sudo :chown, fetch(:safe_deploy_to_owner), fetch(:safe_deploy_to_path)
    end
  end

  desc "Ensures deploy_to directory exists and has the right owner"
  task ensure: [:create, :ensure_owner]
end

before "deploy:check", "safe_deploy_to:ensure"
before "setup", "safe_deploy_to:ensure"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano-safe-deploy-to-1.1.0 lib/capistrano/tasks/safe_deploy_to.rake