Specify docker tag via environment variable

As you mentioned, setting BRANCH in the local shell is too late if you want to use it as the Docker tag. Two approaches that I can think of:

  1. Just change the actual Docker tag name in branches to use the develop tag. This avoids having to use the variable at all. The downside would be remembering to not merge that change to the master branch.
  2. Use CircleCI Workflows and create two jobs. One for the master branch and one for other branches. Each job will use its own specific Docker tag. For steps in the job that are redundant (which may be all of them), a YAML anchor can be used.