Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'lib/ssh_recipes'
- class DeployApplication < SSHRecipes::Recipe
- private
- def execute!
- release = Time.now.utc.strftime("%Y%m%d%H%M%S")
- puts "Release is: #{release}"
- ## create the structure if it doesn't exist yet
- #remove_directory(self.options[:path])
- unless file_exist?(self.options[:path])
- ## create directories
- %w{ releases shared shared/log shared/configs shared/tmp }.each do |dir|
- make_directory(File.join(self.options[:path], dir))
- end
- ## add a known host for the codebase server
- puts "Adding known host for the Codebase server (if appropriate)..."
- add_known_host "gitbase.com", "94.76.230.38", "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAqafgFtYVquYfReJa3MGIyGz0RZoc1kfnXHFDjprY4Uy0lwia+35rRa9Aycrf4eySa55JXsg7rOosqpNOi2hSFWHQ/FfKzMH077Vu1X6d5gNBzxR3aJq/zaAJSiRbrUM20NgEHzBiT8x+32zM71E4qjKnGG8AdEqV9AmROXHWddLSs3e5Tsr2+Dkc/lu+Ko4eVjFjW3ZUgTRE3VTd+PDSRGOfmimgBpcuhkBbEyK4+dq7NJKxLbUl9zC7jKPddkWpbonR9CYWj+c8R8MimKLhhSilNRUKuQBNYydol3eX8VNi+PTzAYtB/w8/jl3+BWzj6xAyfMRdeJDyhhTYX+/s+w=="
- ## clone the repository
- puts "Cloning remote repository for the first time..."
- git_clone File.join(self.options[:path], 'repository'), self.options[:repository]
- else
- puts "Fetching latest repository to remote cached copy..."
- git_fetch File.join(self.options[:path], 'repository')
- end
- ## checkout a copy...
- puts "Cloning from remote cache..."
- git_clone File.join(self.options[:path], 'releases', release), File.join(self.options[:path], 'repository')
- puts "Checking out..."
- git_checkout File.join(self.options[:path], 'releases', release), 'deploy', '3d9d9c2e0f3f31082aecc9594debedc5cf567655'
- ## symlink
- current_path = File.join(self.options[:path], 'current')
- remove(current_path, true)
- puts "Symlinking to #{current_path}..."
- symlink(File.join(self.options[:path], 'releases', release), current_path)
- ## TODO: cleanup after itself...
- end
- end
- server = SSHRecipes::Server.new('router.atechmedia.lan', 'adam')
- deployment = DeployApplication.new(server, :path => "/home/adam/deploytest", :repository => "git@gitbase.com:atech/ssh-recipes/lib")
- begin
- deployment.perform!
- puts deployment.full_output
- rescue SSHRecipes::Error => e
- puts e.inspect
- end
Add Comment
Please, Sign In to add comment