# Can you specify a tag \*and\* a branch?

**URL:** <https://discuss.circleci.com/t/can-you-specify-a-tag-and-a-branch/4282>\
**Category:** Build Environment\
**Created:** [May 31, 2016, 10:27am UTC](https://discuss.circleci.com/t/can-you-specify-a-tag-and-a-branch/4282 "2016-05-31T10:27:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinrenskers](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kevinrenskers/32/13148_2.png) [@kevinrenskers](https://discuss.circleci.com/u/kevinrenskers)\
**Post date:** [May 31, 2016, 10:27am UTC](https://discuss.circleci.com/t/can-you-specify-a-tag-and-a-branch/4282/1 "2016-05-31T10:27:55Z")

</div>

I know I can do something like this to deploy commits in a branch:

```auto
deployment:
  staging:
    branch: develop
    commands:
      - npm run build

```

And according to the docs, you can also build from a tag:

```auto
deployment:
  production:
    tag: /production-.*/
    commands:
      - npm run build

```

But can you combine the two? I only want to create a new production build on new `production-*` tags in the master branch. What if both master and develop are at the same commit and I add a tag. In which branch will the build be created? This matters to me, because based on which branch `npm run build` is run from it creates either a staging or production build.

I’ll change my build script soon to explicitly take a env parameter but for now it’d be good to get this working with the current scripts.

---

<div class="post-metadata">

**Author:** ![kevinrenskers](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kevinrenskers/32/13148_2.png) [@kevinrenskers](https://discuss.circleci.com/u/kevinrenskers)\
**Post date:** [May 31, 2016, 1:02pm UTC](https://discuss.circleci.com/t/can-you-specify-a-tag-and-a-branch/4282/2 "2016-05-31T13:02:19Z")

</div>

Well I just went ahead and made those changes to my build script, so now I specifically run `npm run production` for example.

Would still be nice to know if this would’ve been possible though 🙂

---

<div class="post-metadata">

**Author:** ![FelicianoTech](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/felicianotech/32/21348_2.png) [@FelicianoTech](https://discuss.circleci.com/u/FelicianoTech)\
**Post date:** [June 2, 2016, 7:28pm UTC](https://discuss.circleci.com/t/can-you-specify-a-tag-and-a-branch/4282/3 "2016-06-02T19:28:19Z")

</div>

This is hard because a tag technically has nothing to do with branches, it’s a pointer to a commit. When using a tag, there can be no branch in a way, or multiple branches if a merge occurred at some point.

Personally I would have the script based everything off the tag. A release tag that follows a certain regex pattern for example would be considered “production”. Unless you’re doing continuous deployment in which case I’d ignore tags and just deploy master or a separate “production” branch.

---

<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:38am UTC](https://discuss.circleci.com/t/can-you-specify-a-tag-and-a-branch/4282/4 "2018-06-18T11:38:23Z")

</div>


