Connor Ericson
Connor Ericson

Reputation: 13

Prevent BitBucket from deploying to heroku when pushed to develop

I've set up bitbucket to automatically deploy to Heroku by setting up a bitbucket-pipelines.yml file. The code for that file is included below. Everything is working great. I've got every time I deploy, Heroku picks it up and builds successfully. However, it's happening on both branches. I prefer to only build after a master branch commit. I assume this is possible but solutions I've found don't seem to work.

bitbucket-pipelines.yml file:

image: node:6.9.4

  pipelines:
    default:
      - step:
          caches:
            - node
          script:
            - npm install
            - git push https://heroku:[email protected]/$HEROKU_APP_NAME.git HEAD

Solutions I've tried: (will update as I continue to research)

EDIT: Per VonC's suggestion, I changed my bitbucket-pipelines.yml file to the code below and it works! Thank you so much for your assistance.

image: node:6.9.4

  pipelines:
    branches:
      master:
        - step:
            caches:
              - node
            script:
              - npm install
              - git push https://heroku:[email protected]/$HEROKU_APP_NAME.git HEAD

Upvotes: 1

Views: 39

Answers (1)

VonC
VonC

Reputation: 1324757

This should be what the "Branch workflows" describes:

image: node:5.11.0
pipelines:
  default:
    - step:
        script:
          - echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'."
  branches:
    master:
      - step:
          script:
            - echo "This script runs only on commit to the master branch."
    feature/*:
      - step:
          image: java:openjdk-9 # This step uses its own image
          script:
            - echo "This script runs only on commit to branches with names that match the feature/* pattern."

Upvotes: 1

Related Questions