1

I have a bitbucket pipeline that almost working:

image: atlassian/default-image:2

pipelines:
  default:
    - step:
        services:
          - docker
        script:      
          #Build the image    
          - docker build -t $IMAGE_NAME ./backend
          #Login to heroku's docker registry with an API token
          - docker login --username=_ --password $HEROKU_TOKEN registry.heroku.com

          #Tag and push our built image to the heroku docker registry
          - docker tag $IMAGE_NAME registry.heroku.com/$HEROKU_APPLICATION_NAME/web
          - docker push registry.heroku.com/$HEROKU_APPLICATION_NAME/web

The final step is - I would run something like heroku container:release web -a=$HEROKU_APPLICATION_NAME

How can I do that without actually having the heroku-cli (ie. from the bitbucket pipeline).

dwjohnston
  • 231
  • 3
  • 11

1 Answers1

1

You can install the Heroku CLI via npm - which might be the simplest.

Note that your Heroku API key has to have the env var name HEROKU_API_KEY for the Heroku CLI to accept it as an auth token (ie. to avoid having to do heroku login).

          - npm install -g heroku

          # build the Docker image (this will use the Dockerfile in the root of the repo)
          - docker build -t $HEROKU_APPLICATION_NAME ./backend
          # authenticate with the Docker Hub registry
          - docker login --username=_ --password $HEROKU_API_KEY registry.heroku.com

          - docker tag $HEROKU_APPLICATION_NAME registry.heroku.com/$HEROKU_APPLICATION_NAME/web
          - docker push registry.heroku.com/$HEROKU_APPLICATION_NAME/web
          - heroku container:release web -a=$HEROKU_APPLICATION_NAME

dwjohnston
  • 231
  • 3
  • 11