Skip to content

Instantly share code, notes, and snippets.

@m3talsmith
Forked from brianjlandau/gist:176754
Created January 4, 2010 02:01

Revisions

  1. @brianjlandau brianjlandau revised this gist Sep 9, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -55,7 +55,7 @@

    desc "Rewrite reflog so HEAD@{1} will continue to point to at the next previous release."
    task :cleanup, :except => { :no_release => true } do
    run "git reflog delete --rewrite HEAD@{1}; git reflog delete --rewrite HEAD@{1}"
    run "cd #{current_path}; git reflog delete --rewrite HEAD@{1}; git reflog delete --rewrite HEAD@{1}"
    end

    desc "Rolls back to the previously deployed version."
  2. @brianjlandau brianjlandau revised this gist Sep 1, 2009. 1 changed file with 11 additions and 2 deletions.
    13 changes: 11 additions & 2 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,11 @@
    set :scm, :git
    set :repository, "git@github.com:defunkt/github.git"
    set :branch, "origin/master"
    set :migrate_target, :current

    set(:latest_release) { fetch(:current_path) }
    set(:release_path) { fetch(:current_path) }
    set(:latest_release) { fetch(:current_path) }
    set(:release_path) { fetch(:current_path) }
    set(:current_release) { 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 }
    @@ -36,6 +38,13 @@
    run "cd #{current_path}; git fetch origin; git reset --hard #{branch}"
    finalize_update
    end

    desc "Update the database (overwritten to avoid symlink)"
    task :migrations do
    update_code
    migrate
    restart
    end

    namespace :rollback do
    desc "Moves the repo back to the previous version of HEAD"
  3. @brianjlandau brianjlandau revised this gist Aug 28, 2009. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    # you'd obviously have more settings somewhere
    set :scm, :git
    set :scm, :git
    set :repository, "git@github.com:defunkt/github.git"
    set :branch, "origin/master"

    set(:latest_release) {fetch(:current_path)}
    set(:release_path) {fetch(:current_path)}
    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 }
    @@ -15,11 +15,13 @@
    task :default do
    update
    restart
    cleanup
    end

    desc "Setup a GitHub-style deployment."
    task :setup, :except => { :no_release => true } do
    dirs = [deploy_to, shared_path]
    dirs += shared_children.map { |d| File.join(shared_path, d) }
    run "#{try_sudo} mkdir -p #{dirs.join(' ')} && #{try_sudo} chmod g+w #{dirs.join(' ')}"
    run "git clone #{repository} #{current_path}"
    end

  4. @brianjlandau brianjlandau revised this gist Aug 28, 2009. 1 changed file with 11 additions and 5 deletions.
    16 changes: 11 additions & 5 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -36,15 +36,21 @@
    end

    namespace :rollback do
    desc "Rolls back to the previously deployed version."
    task :code, :except => { :no_release => true } do
    set :branch, "HEAD^"
    desc "Moves the repo back to the previous version of HEAD"
    task :repo, :except => { :no_release => true } do
    set :branch, "HEAD@{1}"
    deploy.default
    end

    desc "Rewrite reflog so HEAD@{1} will continue to point to at the next previous release."
    task :cleanup, :except => { :no_release => true } do
    run "git reflog delete --rewrite HEAD@{1}; git reflog delete --rewrite HEAD@{1}"
    end

    desc "Rolls back to the previously deployed version."
    task :default do
    rollback.code
    rollback.repo
    rollback.cleanup
    end
    end
    end
    end
  5. @brianjlandau brianjlandau revised this gist Aug 28, 2009. 1 changed file with 26 additions and 4 deletions.
    30 changes: 26 additions & 4 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,15 @@
    # you'd obviously have more settings somewhere
    set :scm, :git
    set :repository, "git@github.com: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
    @@ -14,15 +22,29 @@
    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

    desc "Rollback a single commit."
    task :rollback, :except => { :no_release => true } do
    set :branch, "HEAD^"
    default
    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
  6. @defunkt defunkt revised this gist Aug 5, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@
    run "cd #{current_path}; git fetch origin; git reset --hard #{branch}"
    end

    desc "Rollback a failed deploy."
    desc "Rollback a single commit."
    task :rollback, :except => { :no_release => true } do
    set :branch, "HEAD^"
    default
  7. @defunkt defunkt revised this gist Aug 5, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # you'd obviously have more settings somewhere
    set :repository, "git@github.com:defunkt/github.git"
    set :branch, "master"
    set :branch, "origin/master"

    namespace :deploy do
    desc "Deploy the MFer"
  8. @defunkt defunkt created this gist Aug 5, 2009.
    28 changes: 28 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    # you'd obviously have more settings somewhere
    set :repository, "git@github.com:defunkt/github.git"
    set :branch, "master"

    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

    desc "Update the deployed code."
    task :update_code, :except => { :no_release => true } do
    run "cd #{current_path}; git fetch origin; git reset --hard #{branch}"
    end

    desc "Rollback a failed deploy."
    task :rollback, :except => { :no_release => true } do
    set :branch, "HEAD^"
    default
    end
    end