Workflow or Job Rule Does Not Overwrite Default Variable

Issue

I want to set the job runner tag with a variable and to set that variable depending on the value of another one. I set the default variable and then I try to overwrite it either on the workflow or the job level, but apparently, none of them do the trick:

The variable is set like this:

variables:
  RUNNER_TAG: ""

And then in the workflow, I tried this:

workflow:
  name: $PIPELINE_NAME
  rules:
    - if: '$ENV == "dev"'
      variables:
        RUNNER_TAG: runner_dev

This did not work, so I tried on the job level too:

job:
  stage: PLAN
  extends:
    - .default
  script:
    - echo $ENV
  rules:
    - if: '$ENV == "dev"'
      variables:
        RUNNER_TAG: runner_dev
      when: on_success
  tags:
    - ${RUNNER_TAG}

The $ENV is passed properly, the echo spits it out as expected

During the run the job is stuck as the variable is not passed to the tags properly, thus the runner is not found.

Neither of the manners works, despite I’m following the GitLab official documentation:

I have the same problem, would be nice if someone could give some feedback

update, problem solved/mitigated:
my colleague had a good idea, the variable can be overwritten in the before_script block based on conditions.
my case for example:

builder:
  stage: build
  before_script:
    - |
      if [[ "$CI_COMMIT_MESSAGE" =~ .*test_skip.* ]]; then
        MAVEN_PROFILE="skip-tests"
      fi
  extends: .builder_template