Skip to content

Instantly share code, notes, and snippets.

@karmi
Created June 17, 2010 13:21
Show Gist options
  • Select an option

  • Save karmi/442106 to your computer and use it in GitHub Desktop.

Select an option

Save karmi/442106 to your computer and use it in GitHub Desktop.

Revisions

  1. karmi revised this gist Oct 24, 2010. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion post-receive-deploy.rb
    Original file line number Diff line number Diff line change
    @@ -5,14 +5,16 @@
    # INSTALL
    #
    # $ curl http://gist.github.com/442106.txt -o post-receive
    # $ mv post-receive path/to/to/your/repo/.../hooks/post-receive
    # $ mv post-receive path/to/to/your/repo.git/hooks/post-receive
    # $ chmod +x post-receive

    INPUT = STDIN.read.strip
    # puts INPUT.inspect # DEBUG

    # === CONFIGURE THE SCRIPT HERE =================
    deploy_branch = 'deploy'
    application_path = '/www/data/applications/myapp'
    # ===============================================

    old_revision,
    new_revision,
  2. karmi revised this gist Oct 24, 2010. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions post-receive-deploy.rb
    Original file line number Diff line number Diff line change
    @@ -23,12 +23,11 @@
    DEPLOY_COMMAND =<<-END
    (
    unset GIT_DIR \
    &&
    && \
    cd #{application_path} \
    && \
    git \
    fetch --quiet \
    && \
    && \
    git fetch --quiet \
    && \
    git reset --hard -q origin/#{deploy_branch}
    )
    END
  3. karmi revised this gist Oct 24, 2010. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions post-receive-deploy.rb
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,8 @@

    DEPLOY_COMMAND =<<-END
    (
    unset GIT_DIR \
    &&
    cd #{application_path} \
    && \
    git \
  4. karmi revised this gist Jun 17, 2010. 1 changed file with 45 additions and 1 deletion.
    46 changes: 45 additions & 1 deletion post-receive-deploy.rb
    Original file line number Diff line number Diff line change
    @@ -1 +1,45 @@
    # Example script to deploy a Rails application via Git post-receive hook
    #!/usr/bin/env ruby

    # Example script to deploy a Rails application via Git post-receive hook
    #
    # INSTALL
    #
    # $ curl http://gist.github.com/442106.txt -o post-receive
    # $ mv post-receive path/to/to/your/repo/.../hooks/post-receive
    # $ chmod +x post-receive

    INPUT = STDIN.read.strip
    # puts INPUT.inspect # DEBUG

    deploy_branch = 'deploy'
    application_path = '/www/data/applications/myapp'

    old_revision,
    new_revision,
    branch = INPUT.split(' ')

    if branch =~ Regexp.new(deploy_branch)

    DEPLOY_COMMAND =<<-END
    (
    cd #{application_path} \
    && \
    git \
    fetch --quiet \
    && \
    git reset --hard -q origin/#{deploy_branch}
    )
    END

    RESTART_COMMAND =<<-END
    (
    touch #{application_path}/tmp/restart.txt
    )
    END

    puts "Updating application code..."
    system DEPLOY_COMMAND
    puts "Restarting application..."
    system RESTART_COMMAND

    end
  5. karmi created this gist Jun 17, 2010.
    1 change: 1 addition & 0 deletions post-receive-deploy.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    # Example script to deploy a Rails application via Git post-receive hook