# Deploy same branch to multiple apps

**URL:** <https://discuss.circleci.com/t/deploy-same-branch-to-multiple-apps/1886>\
**Category:** Deployments\
**Tags:** heroku, circle-yml\
**Created:** [February 3, 2016, 9:10am UTC](https://discuss.circleci.com/t/deploy-same-branch-to-multiple-apps/1886 "2016-02-03T09:10:39Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![glennr](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/glennr/32/1366_2.png) [@glennr](https://discuss.circleci.com/u/glennr)\
**Post date:** [February 3, 2016, 9:10am UTC](https://discuss.circleci.com/t/deploy-same-branch-to-multiple-apps/1886/1 "2016-02-03T09:10:39Z")

</div>

How do I get the same branch pushed to multiple apps?

I’ve got 3 labels in the deployment section (ci, staging, prod), all pushing a master branch (to a heroku app)

The problem is, only the first one (ci) gets executed i.e. [https://monosnap.com/file/e0eKZoKl9ut5rB6dx4OKw3soqacr2y](https://monosnap.com/file/e0eKZoKl9ut5rB6dx4OKw3soqacr2y)

My circle.yml looks like this

```
deployment:
  ci:
    branch: master
    commands:
      - "[[! -s \"$(git rev-parse --git-dir)/shallow\"]] || git fetch --unshallow"
      - git push git@heroku.com:ff-api-ci.git $CIRCLE_SHA1:refs/heads/master --force 2>&1
  staging:
    branch: master
    commands:
      # Manually fetch full repo
      - "[[! -s \"$(git rev-parse --git-dir)/shallow\"]] || git fetch --unshallow"
      - git push git@heroku.com:ff-api-staging.git $CIRCLE_SHA1:refs/heads/master --force 2>&1
  prod:
    branch: master
    commands:
      # Manually fetch full repo
      - "[[! -s \"$(git rev-parse --git-dir)/shallow\"]] || git fetch --unshallow"
      - git push git@heroku.com:ff-api-prod.git $CIRCLE_SHA1:refs/heads/master --force 2>&1
```

---

<div class="post-metadata">

**Author:** ![glennr](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/glennr/32/1366_2.png) [@glennr](https://discuss.circleci.com/u/glennr)\
**Post date:** [February 4, 2016, 7:00am UTC](https://discuss.circleci.com/t/deploy-same-branch-to-multiple-apps/1886/2 "2016-02-04T07:00:37Z")

</div>

> [@glennr](#):
>
> The problem is, only the first one (ci) gets executed i.e. [Monosnap](https://monosnap.com/file/e0eKZoKl9ut5rB6dx4OKw3soqacr2y)

AFAICT from the documentation, multiple labels are just fine? So I’m wondering if this is a bug?

---

<div class="post-metadata">

**Author:** ![talvola](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/talvola/32/1521_2.png) [@talvola](https://discuss.circleci.com/u/talvola)\
**Post date:** [February 11, 2016, 12:16am UTC](https://discuss.circleci.com/t/deploy-same-branch-to-multiple-apps/1886/3 "2016-02-11T00:16:37Z")

</div>

I see the same thing - see this on CircleCI at the top of the build:

```
     There are multiple applicable deployment sections! Using 'production'.

```

when I have both a ‘production’ and ‘staging’ off of branch:master

We are going to have multiple ‘production’ apps from the same codebase and we will need a way to deploy to both apps. Any workaround (have one deployment kick off another?) much appreciated!

---

<div class="post-metadata">

**Author:** ![gregorynicholas](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/gregorynicholas/32/6049_2.png) [@gregorynicholas](https://discuss.circleci.com/u/gregorynicholas)\
**Post date:** [February 11, 2016, 7:06am UTC](https://discuss.circleci.com/t/deploy-same-branch-to-multiple-apps/1886/4 "2016-02-11T07:06:48Z")

</div>

have you tried deploying with version release tags, prefixed with an `app-id` vs trying to deploy from a branch … ?

going through the same process now, figured having multiple `develop`, `stage`, `prod` branches would be an inherent nightmare (to my already existing disgust of a reality…) , and that having one branch across all apps, but tagging releases for different commits per `app-id` to be a simpler solution, so far so good .

---

<div class="post-metadata">

**Author:** ![travi](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/travi/32/2601_2.png) [@travi](https://discuss.circleci.com/u/travi)\
**Post date:** [April 22, 2016, 4:20am UTC](https://discuss.circleci.com/t/deploy-same-branch-to-multiple-apps/1886/5 "2016-04-22T04:20:28Z")

</div>

I’ve run into this issue as well.

I would like to continue deploying my app to heroku when the master branch builds, but also start to publish a static site for the component library for this app to GitHub Pages, also limited to only the master branch.

The deployment section seems like the appropriate place to manage this, with the available multiple subsections. The only detail in the documentation that seems to suggest that my approach is not appropriate is the following:

> In instances of multiple branches, the first one that matches the branch being built is the one that is run.

Since it seems like this is an intentional limitation, are there other options? I attempted to do the deploy to GitHub Pages as a `post` step under `test`, but I could not figure out how to limit it to only deploy when building the master branch.

---

<div class="post-metadata">

**Author:** ![rpbaptist](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rpbaptist](https://discuss.circleci.com/u/rpbaptist)\
**Post date:** [June 10, 2016, 11:44am UTC](https://discuss.circleci.com/t/deploy-same-branch-to-multiple-apps/1886/6 "2016-06-10T11:44:14Z")

</div>

I ran into the same problem. I really don’t understand why this behaviour would be limited on purpose.

---

<div class="post-metadata">

**Author:** ![blrnw3](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@blrnw3](https://discuss.circleci.com/u/blrnw3)\
**Post date:** [June 30, 2016, 10:45pm UTC](https://discuss.circleci.com/t/deploy-same-branch-to-multiple-apps/1886/7 "2016-06-30T22:45:10Z")

</div>

+1  
This is a blocker for me. [@CircleCI-Employees](https://discuss.circleci.com/groups/CircleCI-Employees)  
Should be able to have multiple deploy sections run in the same build

---

<div class="post-metadata">

**Author:** ![bennibu](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bennibu](https://discuss.circleci.com/u/bennibu)\
**Post date:** [July 1, 2016, 3:14pm UTC](https://discuss.circleci.com/t/deploy-same-branch-to-multiple-apps/1886/8 "2016-07-01T15:14:41Z")

</div>

+1

For our project we need to build artifacts on every branch but want to push some package files to gemnasium only on pushes to master. How do we accomplish this?

---

<div class="post-metadata">

**Author:** ![behalka](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@behalka](https://discuss.circleci.com/u/behalka)\
**Post date:** [August 8, 2016, 8:43am UTC](https://discuss.circleci.com/t/deploy-same-branch-to-multiple-apps/1886/9 "2016-08-08T08:43:35Z")

</div>

+1 I also have one codebase running in two Heroku apps …

---

<div class="post-metadata">

**Author:** ![renatoargh](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/renatoargh/32/14401_2.png) [@renatoargh](https://discuss.circleci.com/u/renatoargh)\
**Post date:** [October 16, 2016, 11:20pm UTC](https://discuss.circleci.com/t/deploy-same-branch-to-multiple-apps/1886/10 "2016-10-16T23:20:56Z")

</div>

> [@blrnw3](#):
>
> +1This is a blocker for me. @CircleCI-EmployeesShould be able to have multiple deploy sections run in the same build

This is also a limitation for me 😕

---

<div class="post-metadata">

**Author:** ![ondrae](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/ondrae/32/15157_2.png) [@ondrae](https://discuss.circleci.com/u/ondrae)\
**Post date:** [January 11, 2017, 4:55am UTC](https://discuss.circleci.com/t/deploy-same-branch-to-multiple-apps/1886/11 "2017-01-11T04:55:25Z")

</div>

Hey. I figured it out.

You can have one deployment section which can include multiple deploys.

```
deployment:
   demo_and_countyportal:
     branch: puma-on-heroku
     commands:
       - git push git@heroku.com:gcfdemo.git $CIRCLE_SHA1:master
       - heroku run rake db:migrate --app gcfdemo
       - git push git@heroku.com:gcfcountyportal.git $CIRCLE_SHA1:master
       - heroku run rake db:migrate --app gcfcountyportal
```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:40am UTC](https://discuss.circleci.com/t/deploy-same-branch-to-multiple-apps/1886/12 "2018-06-18T11:40:56Z")

</div>

Closed on June 18, 2018, 11:40am UTC


