# A part of custom deploy condition is ignored

**URL:** <https://travis-ci.community/t/a-part-of-custom-deploy-condition-is-ignored/6897>\
**Category:** Travis CI Discussions & Feedback\
**Tags:** deploy-conditions\
**Created:** [January 17, 2020, 10:04am UTC](https://travis-ci.community/t/a-part-of-custom-deploy-condition-is-ignored/6897 "2020-01-17T10:04:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![markDz](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@markDz](https://travis-ci.community/u/markDz)\
**Post date:** [January 17, 2020, 10:04am UTC](https://travis-ci.community/t/a-part-of-custom-deploy-condition-is-ignored/6897/1 "2020-01-17T10:04:39Z")

</div>

Hi all,  
this is my yml file

```
   language: scala

jdk:
  - openjdk8

before_install:
  - chmod +x build.sh

install:
  - pyenv install 3.6.1
  - pyenv global 3.6.1
  - pip install --upgrade pip

env:
  - DEPLOY_DEST=staging

services:
  - docker

branches:
  only:
    - master
    - /^v[0-9].*$/

script:
  - ./build.sh test;

before_deploy:
  - pip3 install awscli

deploy:
  - provider: script
    skip_cleanup: true
    script: bash ./build.sh deploy_staging $TRAVIS_TAG
    on:
      tags: true
      all_branches: true
      condition: $TRAVIS_TAG =~ ^v[0-9].*$ && $DEPLOY_DEST=staging
  - provider: script
    skip_cleanup: true
    script: bash ./build.sh deploy_production $TRAVIS_BRANCH
    on:
      tags: false
      all_branches: true
      condition: $TRAVIS_BRANCH =~ ^v[0-9].*$ && $DEPLOY_DEST=production

```

Problem i’m having is: when the branch name starts e.g with v1… after pull request is closed, it deploys to production. I’ve read in documentation that it will deploy when _a single_ bash condition evaluates to `true`. I tried many different options with conditions, but for some reason it’s always ignored and every time i close pull request it deploys production. If I set `branch: /^v[0-9].*$/` than it will not deploy production  
Idea is next:

- Draft a new release on github deploys staging with version e.g v1.0.1
- Triggering custom build on Travis-CI UI with branch:v1.0.1 env: DEPLOY\_DEST=production deploys production

Could you please tell me what I’m doing wrong?

---

<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:** [January 17, 2020, 8:11pm UTC](https://travis-ci.community/t/a-part-of-custom-deploy-condition-is-ignored/6897/3 "2020-01-17T20:11:18Z")

</div>

> [@markDz](#):
>
> condition: $TRAVIS\_BRANCH =~ ^v[0-9].\*$ && $DEPLOY\_DEST=production

This is one of `bash`’s all-too-familiar gotchas with significant spaces:

```auto
$ TRAVIS_BRANCH=v1.0.1
$ set -x
$ if [[( $TRAVIS_BRANCH =~ ^v[0-9].*$ ) && ( $DEPLOY_DEST==production ) ]]; then echo foo; else echo bar; fi
+ [[v1.0.1 =~ ^v[0-9].*$ ]]
+ [[-n ==production]]
+ echo foo
foo

```

As you can see, without spaces around the equal sign, the 2nd condition is not evaluated the way you expect it to.

You need to write the condition as:

```auto
$TRAVIS_BRANCH =~ ^v[0-9].*$ && $DEPLOY_DEST == production

```
