Dynamic Workflow Definition

Hello,

We have a single android project from which we’re building 27 different apps. The backbone of these apps is more or less the same. Some features are different or enabled only on some of the brands, but overall the apps look very similar to each other.

I use environment variable to determine which customers to build for. Environment variable and configuration definition are as follows:

TENANT_NAMES=‘customer1;customer2’

version: 2.1
jobs:
  build_apk:
    description: "Build Apk"
    steps:
      - checkout
      - run:
          name: Assemble << parameters.tenantName >> apk
          command: |
          for TENANT_NAME in $(echo ${TENANT_NAMES} | tr ";" "\n")
          do
            ./gradlew app:assemble${TENANT_NAME}
          done

I want to run build process in parallel to shorten the execution time. I have done this by adiing the following lines and it works great.

    jobs:
      build_customer_1:
        <<: *android_config
        steps:
          - build_apk:
              tenantName: "customer1"

      build_customer_2:
        <<: *android_config
        steps:
          - build_apk:
              tenantName: "customer2"

    workflows:
      workflow:
        jobs:
          - build_customer_1
          - build_customer_2

In the next step, I want to define workflow dynamically according to TENANT_NAMES. However, I couldn’t find how to do that. Can you help me please?