Skip to content

Instantly share code, notes, and snippets.

@m3talsmith
Forked from brianjlandau/gist:176754
Created January 4, 2010 02:01
Show Gist options
  • Save m3talsmith/268233 to your computer and use it in GitHub Desktop.
Save m3talsmith/268233 to your computer and use it in GitHub Desktop.
A Capistrano Recipe using Git as the folder structure, not just the scm.
# you'd obviously have more settings somewhere
set :scm, :git
set :repository, "[email protected]:defunkt/github.git"
set :branch, "origin/master"
set(:latest_release) {fetch(:current_path)}
set(:release_path) {fetch(:current_path)}
set(:current_revision) { capture("cd #{current_path}; git rev-parse --short HEAD").strip }
set(:latest_revision) { capture("cd #{current_path}; git rev-parse --short HEAD").strip }
set(:previous_revision) { capture("cd #{current_path}; git rev-parse --short HEAD@{1}").strip }
namespace :deploy do
desc "Deploy the MFer"
task :default do
update
restart
cleanup
end
desc "Setup a GitHub-style deployment."
task :setup, :except => { :no_release => true } do
run "git clone #{repository} #{current_path}"
end
task :update do
transaction do
update_code
end
end
desc "Update the deployed code."
task :update_code, :except => { :no_release => true } do
run "cd #{current_path}; git fetch origin; git reset --hard #{branch}"
finalize_update
end
namespace :rollback do
desc "Rolls back to the previously deployed version."
task :code, :except => { :no_release => true } do
set :branch, "HEAD^"
deploy.default
end
desc "Rolls back to the previously deployed version."
task :default do
rollback.code
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment