# Running a branch conditional

**URL:** <https://travis-ci.community/t/running-a-branch-conditional/11554>\
**Category:** v2\
**Tags:** travis-build\
**Created:** [May 4, 2021, 12:39pm UTC](https://travis-ci.community/t/running-a-branch-conditional/11554 "2021-05-04T12:39:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SolarUltima](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/solarultima/32/4019_2.png) [@SolarUltima](https://travis-ci.community/u/SolarUltima)\
**Post date:** [May 4, 2021, 12:39pm UTC](https://travis-ci.community/t/running-a-branch-conditional/11554/1 "2021-05-04T12:39:45Z")

</div>

I working on a project (same project), and im trying to deploy conditionals for branches, example: anything merged into the `develop` branch, I want to end up on `https://dev.mysite` , but anything merged into the `master` branch, I want deployed to `https://www.mysite.com` .

```auto
language: csharp
mono: none
sudo: required
dist: xenial
dotnet: 2.2
branches:
only:
    - master
    - develop
before_script:
- chmod -R a+x scripts
script:
- "./scripts/docker-publish-travis.sh"
after_success:
- "./scripts/after-success.sh"
notifications:
email:
    on_success: never
    on_failure: always

```

is it even possible to add a conditional to the above `.travis.yml` file so that if the branch is `develop` , a different script is run?

**develop branch**

```auto
script:
    - "./scripts/docker-publish-travis-develop.sh"

```

**master branch**

same path as develop.sh

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [May 4, 2021, 12:43pm UTC](https://travis-ci.community/t/running-a-branch-conditional/11554/2 "2021-05-04T12:43:00Z")

</div>

Hey,

Seems like you’re over complicating things. A simple if/else bash script would solve this.

You should try calling the same script for both `develop and master` using ( `./scripts/docker-publish-travis.sh` ), and maybe have this script do something else based on the `$TRAVIS_BRANCH` environment variable?

```auto
if [["$TRAVIS_BRANCH" == "master"]]; then
  # Push to the master branch here
else
  # Push to the develop branch here
fi

```

Remember to give it permissions, seems to me this would be the easiest fix. Good luck.

Happy building!  
Montana Mendy
