# Build on master, tags and pull requests; deploy in the first two cases

**URL:** <https://travis-ci.community/t/build-on-master-tags-and-pull-requests-deploy-in-the-first-two-cases/4476>\
**Category:** Travis CI Discussions & Feedback\
**Tags:** conditions, travis-yml, deploy-conditions\
**Created:** [July 31, 2019, 6:08pm UTC](https://travis-ci.community/t/build-on-master-tags-and-pull-requests-deploy-in-the-first-two-cases/4476 "2019-07-31T18:08:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![althurman](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@althurman](https://travis-ci.community/u/althurman)\
**Post date:** [July 31, 2019, 6:08pm UTC](https://travis-ci.community/t/build-on-master-tags-and-pull-requests-deploy-in-the-first-two-cases/4476/1 "2019-07-31T18:08:22Z")

</div>

Hello All,

I am trying to figure out how to setup more than one build for my git hub repository. I would like to have 3 builds

1. A manual build that does a release and pushes the resulting nuget to my private feed
2. A build that is triggered when there is a delivery to my master branch (deploys a different nuget)
3. A build that is triggered by a delivery to any branch that has a pull request

I do not see how to add different builds for a repo in the web browser. Do I have to add logic to my .yml file to get these different builds? Any guidance on this is appreciated

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [August 1, 2019, 10:22am UTC](https://travis-ci.community/t/build-on-master-tags-and-pull-requests-deploy-in-the-first-two-cases/4476/2 "2019-08-01T10:22:01Z")

</div>

This looks like a job for™ [conditional build](https://docs.travis-ci.com/user/conditional-builds-stages-jobs) and [conditional deployment](https://docs.travis-ci.com/user/deployment/#conditional-releases-with-on):

```auto
if: branch = master OR type = pull_request OR tag IS present
<...>
deploy:
  on:
    condition: "$TRAVIS_BRANCH" == "master" || -n "$TRAVIS_TAG"
  <...>

```

The “manual build” will be triggered by tagging the commit. Alternatively, you can [trigger it manually via UI or API](https://blog.travis-ci.com/2017-08-24-trigger-custom-build) – then you’ll need to set some other indicator in the custom config like an envvar and replace the tag conditions appropriately.

---

<div class="post-metadata">

**Author:** ![althurman](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@althurman](https://travis-ci.community/u/althurman)\
**Post date:** [August 1, 2019, 2:34pm UTC](https://travis-ci.community/t/build-on-master-tags-and-pull-requests-deploy-in-the-first-two-cases/4476/3 "2019-08-01T14:34:56Z")

</div>

Thanks for the help. i think my biggest problem is that I can’t find adequate documentation on the syntax of the .yml file (as i figured this logic could be done in the .yml file initially just can’t figure out exactly how). I tried adding the if: as you mentioned. Basically just a test to list the files in TRAVIS\_BUILD\_DIR if I’m building off master (see below). Seems that is not right as it did not even build in Travis. Can you point me to some documentation that describes the syntax of the .yml file. Or maybe some .yml that has an example of how to do this?

My .yml:

**sudo: required**  
**language: csharp**

**mono: none**  
**dotnet: 2.0.0**

**script:**  
**- dotnet restore ./src/MySolution.sln**  
**- dotnet msbuild ./src/MySolution.sln**

**if: branch = master**  
**- find $TRAVIS\_BUILD\_DIR**

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [August 1, 2019, 4:02pm UTC](https://travis-ci.community/t/build-on-master-tags-and-pull-requests-deploy-in-the-first-two-cases/4476/4 "2019-08-01T16:02:08Z")

</div>

A YAML file is not a program. Its top level represents a hash table (like JSON), so the order of the keys is not significant (and is actually undefined in the data structure that it’s parsed into).  
As such, `if:` is not a conditional block. As per the linked article, it rather sets a condition when the entire build should be triggered.
