For anyone trying this out, after talking to Circle folks, I had to change the timeout call to be between brackets circle.yml to
deployment:
production:
branch: master
commands:
- ./script/heroku_deploy.sh myHerokuApp $CIRCLE_SHA1: { timeout: 400 }
- ./script/heroku_deploy_restart.sh myHerokuApp
My script now has takes variables, appName and CircleSha:
#!/bin/sh -e
APP_NAME=$1
CIRCLE_SHA1=$2
#and so on...
(I also had problems with the PREV_WORKERS line not working as expected so I hard coded it in my case.)
Another issue to consider is that in the case of a timeout you might not be restarting workers or putting application back off maintenance mode.
Thus I move those commands to a second script called heroku_deploy_restart.sh
#!/bin/sh -e
APP_NAME=$1
#restart background workers once finished
heroku scale worker=1 --app $APP_NAME
heroku run rake memcached:flush --app $APP_NAME
heroku maintenance:off --app $APP_NAME