Dynamic Config based on changed files

(note: response generated by AI, sourced from CircleCI assets)
Based on the provided configuration, you are already using the circleci/path-filtering orb to detect changes in specific directories and trigger corresponding workflows. However, you want to modify this behavior such that when changes are made both in the helm/ directory and somewhere else, only the build-deploy workflow should run.

To achieve this, you could modify the mapping in your config.yml file to set the only_deploy parameter to true only when changes are exclusively in the helm/ directory. This can be done by adding a negative lookahead in the regular expression for the build_deploy parameter to exclude changes in the helm/ directory. Here’s how you can modify the mapping:

mapping: |
  ^(?!helm/).* build_deploy true
  ^helm/.*$ only_deploy true

In this configuration:

  • The build_deploy parameter is set to true when changes are made anywhere except the helm/ directory.
  • The only_deploy parameter is set to true only when changes are exclusively in the helm/ directory.

This way, if changes are made both in the helm/ directory and somewhere else, only the build-deploy workflow will run.

Please note that this solution assumes that the circleci/path-filtering orb supports negative lookaheads in regular expressions. If it doesn’t, this solution may not work.

For more information on how to use the circleci/path-filtering orb, you can refer to the CircleCI Developer Hub and the CircleCI Docs.

Sources: