I am trying to deploy with Travis CI to 2 different providers(npm, firebase), my .travis.yml file looks something like this:
branches:
  only:
    - master
    - /v\d+\.\d+\.\d+/
install:
  - yarn
before_deploy:
  # first provider
  - yarn build:storybook
  # second provider
  - yarn build:library
  - cp package.json lib/
  - cd lib
deploy:
  - provider: firebase
    ...
    on:
      branch: master
  - provider: npm
    ...
    on:
      tags: true
      all_branches: true
Now I would like to trigger #first provider block inside before_deploy only when I am deploying to firebase (master). 
Is there some way to have a condition inside before_deploy? Or even a only: -branch-name inside before_deploy?
 
                        
You can specify your condition as a bash script:
What this does is prevent the script from running
yarn build:storybookwhen someone makes a new pull request to master; but only runs when the master branch is built by travis due to a push (or whatever triggers the build).See here for more variables: https://docs.travis-ci.com/user/environment-variables/#default-environment-variables