How to optimize my build

Hi friends, a newbie to Travis here. I have a following Angular CI config, and I have three questions:

  1. is the CODECOV_TOKEN=$CODECOV_TOKEN here unnecessary since it is already exported from the settings?
  2. I only want to run the Deploy stage on master branch, but the stage is still triggered on other branch, so if: branch = master is not working here?
  3. I want to install chrome by default and now used in Test stage, but override it and install gettext-base package in the Deploy phase, how can I achieve this nicely?

Any other optimization tips are greatly appreciated :pray:t2:

dist: trusty
sudo: false

language: node_js
node_js:
  - "12"

addons:
  chrome: stable
  apt:
    update: true
    packages:
      - gettext-base

env:
  global:
    CODECOV_TOKEN=$CODECOV_TOKEN

cache:
  directories:
     - ./node_modules

install:
  - npm install

stages:
  - name: Lint & Test
  - name: Deploy to Firebase
    if: branch = master

jobs:
  include:
    - stage: Lint & Test
      script:
        - npm run lint

    - stage: Lint & Test
      script:
        - npm run test -- --no-watch --no-progress --code-coverage --browsers=ChromeHeadless
      after_script:
        - if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then ./node_modules/.bin/codecov; fi

    - stage: Deploy to Firebase
      skip_cleanup: true
      script:
        - npm run build -- --prod --output-path=dist
      before_deploy:
        - envsubst < ./dist/assets/env.template.js > ./dist/assets/env.js 
      deploy:
        provider: firebase
        token: $FIREBASE_TOKEN
        edge: true

An example pipeline here