AWS ECR orb passing repo as bash subshell command

I’m trying to use a subshell that will give a different value depending on the type of github branch ‘release’ or ‘master’ (production/development).

Here is my code:

  - aws-ecr/build-and-push-image:
      path: ./dev
      repo: |
        $(
        name=$(npm run name --silent)
        if [[ "${CIRCLE_BRANCH}" == "release" ]]; 
        then echo "$name"; 
        else echo "$(echo $name)-dev"; 
        fi)
      tag: $(npm run version --silent)

The error I’m getting

#!/bin/bash -eo pipefail
docker build \
   \
  -f Dockerfile \
  -t $AWS_ECR_ACCOUNT_URL/$(name=$(npm run name --silent)
if [[ "${CIRCLE_BRANCH}" == "release" ]] ; 
then echo "$(echo $name)"; 
else echo "$(echo $name)-dev"; 
fi)
:$(npm run version --silent) \
  ./dev
"docker build" requires exactly 1 argument.
See 'docker build --help'.

Usage:  docker build [OPTIONS] PATH | URL | -

Build an image from a Dockerfile
Exited with code 1

Previously I just had repo: $(npm run name --silent) - this is working fine, but once I added the conditional logic it fails. I’m not sure where is the issue.

Could you swap the logic?

  1. Check which branch
  2. Set an ENV VAR (rather than echo)
  3. Pass the ENV VAR into the docker command