Skip to content

Instantly share code, notes, and snippets.

@flomotlik
Last active January 10, 2020 21:40
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flomotlik/4136579 to your computer and use it in GitHub Desktop.
Save flomotlik/4136579 to your computer and use it in GitHub Desktop.
Heroku run script that exits with the correct error code
#! /bin/bash
array=( $@ )
len=${#array[@]}
app=${array[$len-1]}
args=${array[@]:0:$len-1}
buffer_file=/tmp/last_heroku_run_`date +%N`
/usr/bin/heroku run "$args; echo \$?" --app $app 2>&1 | tee $buffer_file
exit `tail -1 $buffer_file`
#Run with heroku_run 'bundle exec rake db:migrate' MY_HEROKU_APP_NAME
@Taytay
Copy link

Taytay commented Sep 3, 2014

Thanks! Very helpful!

@kris-luminar
Copy link

Does anyone have an example of how to use this in a Travis CI script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment