Skip to content

Instantly share code, notes, and snippets.

@remino
Created August 26, 2013 09:41

Revisions

  1. remino created this gist Aug 26, 2013.
    30 changes: 30 additions & 0 deletions git-deploy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    #!/bin/sh

    # git-deploy
    #
    # - Make sure your deployment environments on Heroku are set as Git remotes:
    # git remote add production [email protected]:example-production.git
    # git remote add staging [email protected]:example-staging.git
    #
    # - Have branch names matching those environments:
    # git checkout -b production
    # git push origin production
    # git checkout -b staging
    # git push origin staging
    #
    # - Call git deploy branch_name:
    # It will call "git push branch_name branch_name:master" to deploy your app.

    git_deploy() {
    [ $# -lt 1 ] && git_deploy_usage && return 1

    git push $1 $1:master
    }

    git_deploy_usage() {
    echo "usage: git deploy [branch_name]"
    echo
    echo "The branch_name must match the Git remote name for Heroku."
    }

    git_deploy $@