deployment:
  master:
    branch: master
    commands:
      - heroku maintenance:on --app ${HEROKU_APP_NAME}
      - git push git@heroku.com:${HEROKU_APP_NAME}.git $CIRCLE_SHA1:master
      - heroku run rake db:migrate --app ${HEROKU_APP_NAME}
      - heroku maintenance:off --app ${HEROKU_APP_NAME}

deployment:
  master:
    branch: master
    commands:
      - heroku maintenance:on --app ${HEROKU_APP_NAME}
      - '[[ ! -s "$(git rev-parse --git-dir)/shallow" ]] || git fetch --unshallow'
      - git push git@heroku.com:${HEROKU_APP_NAME}.git $CIRCLE_SHA1:master
      - heroku run rake db:migrate --app ${HEROKU_APP_NAME}
      - heroku maintenance:off --app ${HEROKU_APP_NAME}

Fix deployment to Heroku through Circle CI
Fix deployment to Heroku through Circle CI