Skip to content

Instantly share code, notes, and snippets.

@jcrisp
Created November 9, 2017 02:50
Show Gist options
  • Save jcrisp/8d0441d1181cdeaff93245c00d65af84 to your computer and use it in GitHub Desktop.
Save jcrisp/8d0441d1181cdeaff93245c00d65af84 to your computer and use it in GitHub Desktop.
task :deploy_pdfs do
on roles(:app) do |h|
execute "mkdir -p #{remote_shared_pdfs_dir}"
rsync_pdfs("#{h.username}@#{h.hostname}")
end
end
task :delete_pdfs do
on roles(:app) do
execute "rm #{remote_shared_pdfs_dir}/*"
end
end
def rsync_pdfs(server)
rsync("#{local_pdfs_dir}/*", "#{server}:#{remote_shared_book_dir}")
end
def rsync(source, destination)
cmd = "rsync -aHxvzh --numeric-ids -e \"ssh -o Compression=no -x\" #{source} #{destination}"
puts cmd
raise "RSYNC FAILED!" unless system(cmd)
end
def remote_shared_pdfs_dir
fetch(:deploy_to) + "/shared/pdfs"
end
def local_pdfs_dir
"#{File.dirname(__FILE__)}/../pdfs"
end
def remote_release_dir
fetch(:deploy_to) + "/current"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment