Is it possible to execute `run` within a for loop?

I’m trying to find a way to work with Circleci 2.1 so that I can trigger workflows of directories that have changed within the repo.

I have my list of changed directories,
Is it possible to execute something like:

        for changeddirectory in changeddirectories; do
                - run: (my list of steps here)

I’ve been trying various combinations of this, but I’ve been unable to execute steps within the shell script.

Any help on this, or a potential other way of implementing this would be greatly appreciated!

Hello @circlecibeginner

All of your logic must be contained within the run step itself. The CircleCI config is parsed yaml which is fed to a processor for the run tasks. The run task itself may contain a bash script for instance which would loop through what actions you need to take.

You can define multiple workflows and trigger a specific workflow with our API. Pipeline Variables - CircleCI

Theoretically you could have one workflow per directory you wish to monitor, then have a main workflow which is responsible for finding out what directory has been modified call the correct workflow trigger via the API.