CircleCI-Public / path-filtering-orb

MIT License
24 stars 62 forks source link

Add support for empty commits #31

Closed nicolai86 closed 1 year ago

nicolai86 commented 3 years ago

Describe Request:

For daily builds we utilize empty github commits to trigger builds on circleci.

This orb would work wonderful for this if it had the ability to set a number of default parameters, which are passed to the continuation pipeline in case no path mapping matches.

Examples:

example usage:

workflows:
  setup-workflow:
    jobs:
      - path-filtering/filter:
          config-path: .circleci/continue_config.yml
          mapping: |
            a/.* build-a true
            b/.* build-b true
          fallback-parameters: |
            {"build-b": true}
          base-revision: origin/master

required code change in set_parameters.py:

mappings = filter(check_mapping, mappings)
mappings = list(map(convert_mapping, mappings))

# if we have no matching path, use fallback parameters in continuation
if len(mappings) > 0:
  mappings = dict(mappings)
  print('using parameters from path filter {}'.format(json.dumps(mappings)))
else:
  fallback = os.environ.get('FALLBACK_PARAMETERS')
  print('using parameters from fallback {}'.format(fallback))
  mappings = dict(json.loads(fallback))
#

now, you can create empty commits which will pass the fallback parameters to the continuation:

git commit --allow-empty -m "Daily build"

Supporting Documentation Links:

elliotforbes commented 1 year ago

Closing this for now as we haven't had any activity on this for some time and this issue may have been resolved since the issue was opened.

If you feel strongly about this change, please feel free to re-open these tickets so that we can prioritise any outstanding work.