Repeat an imported template for a list of values

Hello,

I’m currently writing a gitlab CI script and am using an imported template like this

include:
    - project: "ci-templates"
      file: "work-on-project.yml"
      ref: master

deploy:
  stage: deploy
  image: $MY_IMAGE
  tags:
    - my-gitlab
  script:
    - PROJECT_NAME=project1
    - !reference [.work-on-project, script]
    - PROJECT_NAME=project2
    - !reference [.work-on-project, script]
    - PROJECT_NAME=project3
    - !reference [.work-on-project, script]
  when: manual

Now, this works fine, but it’s quite tedious to repeat the !reference for every value of PROJECT_NAME

I’m thus looking for a way to express a repetition of a !reference with a variable value from a list, similar to this non working syntax:

  variables:
    - PROJECT_NAMES: ['project1', 'project2', 'project3']
  script:
    - foreach PROJECT_NAME in PROJECT_NAMES
      - !reference [.work-on-project, script]

It would also be nice to be able to do it with anchors like this:

  variables:
    - PROJECT_NAMES: ['project1', 'project2', 'project3']
  script:
    - foreach PROJECT_NAME in PROJECT_NAMES
      - *work-on-project

I know I can use the for instruction from the underlying shell, but I can’t figure out a way to invoke a reference or anchor from within a multi-line for construct like this:

  - |+
    for p in $SpaceSeparatedVariable
    do 
      echo working on $p
      CallReferenceScript
    done

Would anyone have any suggestion ?

I’m currently running a 15.3.3 self hosted instance and could update it if needed.