Rules for job

I need help with my build/deploy job. I only want to execute the build job during a merge request but its not firing. The deploy job seems to be working fine. The below will be used as a regular pipeline and as a parent pipeline.

/my-group/my-pipelines/.gitlab-ci-ecs-service.yml

stages:
  - build
  - deploy

variables:
  BUILD_ENVIRONMENT: test

workflow:
  rules:
    - if: '$CI_COMMIT_BRANCH =~ /^master|main|dev$/'
      variables:
        BUILD_ENVIRONMENT: "dev"
    - if: '$CI_COMMIT_BRANCH =~ /^dev2$/'
      variables:
        BUILD_ENVIRONMENT: "dev2"
    - if: '$CI_COMMIT_BRANCH =~ /^qa$/'
      variables:
        BUILD_ENVIRONMENT: "qa"
    - if: '$CI_COMMIT_BRANCH =~ /^trn|training$/'
      variables:
        BUILD_ENVIRONMENT: "trn"
    - if: '$CI_COMMIT_BRANCH =~ /^prod|production$/'
      variables:
        BUILD_ENVIRONMENT: "prod"
    - when: always

build:
  stage: build
  services:
    - docker:19.03.5-dind
  script:
    - echo "$BUILD_ENVIRONMENT"
    - env
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"

deploy:
  stage: deploy
  services:
    - docker:19.03.5-dind
  script:
    - echo "$BUILD_ENVIRONMENT"
  rules:
    - if: $BUILD_ENVIRONMENT == "test"
      when: never
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
      when: never
    - if: $CI_PIPELINE_SOURCE == "schedules"
      when: never
    - if: $CI_PIPELINE_SOURCE == "push"
    - when: always

/my-group/my-project-test/.gitlab-ci.yml

# Package A configuration
Runner:
  # `trigger` is the keyword to create a child pipeline
  trigger:
    # Include the configuration file of the child pipeline
    include: .gitlab-ci-ecs-task.yml
    # With this strategy, the parent only succeed if the child succeed too
    strategy: depend

# Package B configuration
Service:
  # `trigger` is the keyword to create a child pipeline
  trigger:
    # Include the configuration file of the child pipeline
    include: .gitlab-ci-ecs-service.yml
    # With this strategy, the parent only succeed if the child succeed too
    strategy: depend

Slackbot:
  # `trigger` is the keyword to create a child pipeline
  trigger:
    # Include the configuration file of the child pipeline
    include: .gitlab-ci-ecs-slackbot.yml
    # With this strategy, the parent only succeed if the child succeed too
    strategy: depend
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"

/my-group/my-project-test/.gitlab-ci-ecs-task.yml

variables:
  REGION: us-east-1
  ECR_REPO_NAME: runner
  DOCKERFILE: runner.Dockerfile

include:
  - project: 'my-group/my-pipelines'
    ref: 'feature/TP-11627'
    file: '.gitlab-ci-ecs-service.yml'

/my-group/my-project-test/.gitlab-ci-ecs-service.yml

variables:
  REGION: us-east-1
  ECR_REPO_NAME: runner
  DOCKERFILE: runner.Dockerfile
  ECS_CLUSTER_NAME: myman

include:
  - project: 'my-group/my-pipelines'
    ref: 'feature/TP-11627'
    file: '.gitlab-ci-ecs-service.yml'