Conditional Deployment

What’s the correct syntax to deploy if a tag matches a pattern? I’ve tried lots of variants of this, but can’t quite find the right hook.

- provider: script
  script: "bash ./bin/deploy aut"
  skip_cleanup: true
  on:
      tags: true
      condition: ${TRAVIS_TAG} =~ ^\d{8}\.rc\d+$

I’ve also tried all_branches: true instead of tags: true, with and without slashes surrounding the regex, a standalone condition: (i.e., eliminating the line above), etc… The pattern never seems to match. I’d love to know what I’m missing here.

Hi @robwilkerson,

Try something like:

deploy:
  provider: script
  script: bash scripts/deploy.sh production $TRAVIS_TAG
  on:
    tags: true
    all_branches: true
    condition: $TRAVIS_BRANCH =~ ^release\/.*$ && $TRAVIS_OS_NAME = linux

More testing is required, but I think I’ve isolated the problem to the regex itself - specifically its syntax. In the above, I’m using \d, which PCRE, but not POSIX. Early testing indicates that only POSIX might be supported here which makes sense if it’s run via bash under the hood.

Anyway, thought I’d follow up with what I think I know since it’s been a minute.