Migrating Heroku deploy from v1 to v2.0

heroku

#1

I’m trying to migrate a v1 circle.yml to v2.0 and (after a struggle) have everything working except deploying to Heroku.

In v1 I had this:

deployment:
  production:
    branch: master
    commands:
      - heroku maintenance:on --app my-heroku-app
      - heroku scale celery_worker=0 web=0 --app my-heroku-app
      - "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"
      - git push git@heroku.com:my-heroku-app.git $CIRCLE_SHA1:master
      - heroku run python manage.py migrate --app my-heroku-app
      - heroku scale celery_worker=1 web=1 --app my-heroku-app
      - heroku maintenance:off --app my-heroku-app

I’ve got as far as changing it to this for v2.0:

version: 2
jobs:
  build:
    steps:
      # ...
      - deploy:
          name: "Deploy to master"
          command: |
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              heroku maintenance:on --app my-heroku-app
              heroku scale celery_worker=0 web=0 --app my-heroku-app
              "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"
              git push heroku master
              heroku run python manage.py migrate --app my-heroku-app
              heroku scale celery_worker=1 web=1 --app my-heroku-app
              heroku maintenance:off --app my-heroku-app
            fi

But I get the error /bin/bash: line 1: heroku: command not found.

I eventually found the project walkthrough with a bit about deploying to Heroku… but I struggle to work out from that what steps I need to take to get a currently-working-v1 deployment to work with v2.

It looks incredibly complicated which, given Heroku is supposed to make this stuff simple, seems weird. And given I’ve seen posts on here from nearly a year ago saying Heroku stuff will get easier in a few weeks, I assume I’m missing something.

What do I need to do now?


#2

Hi philgyford,

It appears that you are not setting up the heroku cli and so the heroku command is not found.

Before you execute your ‘Deploy to master’ command you should run a set up script in a previous step. Have a look at this example

However, I can’t get this to work as I just run into authentication errors. I really think I’ll wait on the migration to 2.0 until circleci provide a solid heroku integration such as that available in 1.0 as you are correct that it is far too complex and error prone in 2.0


#3

Thanks johnhunsley. Yes, given this is the only project we have on CircleCI, and it’s now very rarely updated, I’m wary of giving this transition too much more of my time. Hopefully they’ll simplify this in due course…


#4

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.