Skip to content

Instantly share code, notes, and snippets.

@Whitespace
Created April 2, 2013 20:43
Show Gist options
  • Save Whitespace/5296004 to your computer and use it in GitHub Desktop.
Save Whitespace/5296004 to your computer and use it in GitHub Desktop.
Some helper functions for heroku deploys. This uses the heroku cli's -r feature to run commands on a git remote, so you need git remotes for production and staging to respectively named.
function p {
command=$1
shift 1
heroku $command -r production $@
}
function s {
command=$1
shift 1
heroku $command -r staging $@
}
function log {
local environment=$1
local type=$2
local source_and_process
local IFS='.'
shift 2
read -ra source_and_process <<< "$type"
local source="${source_and_process[0]}"
local process="${source_and_process[1]}"
if [ -z "$process" ]
then
set -x
$environment logs -s $source $@
set +x
else
set -x
$environment logs -s $source -p $process $@
set +x
fi
}
function deploy {
env=$1
shift 1
echo "say \"Deploying to $env\" && git push $env $@ && say \"Deploy to $env complete\""
say "Deploying to $env" && git push $env $@ && say "Deploy to $env complete"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment