# Manually trigger path-filtered workflow

**URL:** <https://discuss.circleci.com/t/manually-trigger-path-filtered-workflow/42346>\
**Category:** Build Environment\
**Created:** [December 21, 2021, 2:51pm UTC](https://discuss.circleci.com/t/manually-trigger-path-filtered-workflow/42346 "2021-12-21T14:51:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dale.francum](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@dale.francum](https://discuss.circleci.com/u/dale.francum)\
**Post date:** [December 21, 2021, 2:51pm UTC](https://discuss.circleci.com/t/manually-trigger-path-filtered-workflow/42346/1 "2021-12-21T14:51:25Z")

</div>

When using the path filtering orb to run workflows, I’m looking for a better method of manually triggering a workflow. As an example, let’s say I have this setup:

```auto
version: 2.1
setup: true
orbs:
  path-filtering: circleci/path-filtering@0.1.1
workflows:
  setup:
    jobs:
      - path-filtering/filter:
          base-revision: main
          config-path: .circleci/workflows.yml
          mapping: |
            dir_a/.* run-workflow-a true
            dir_b/.* run-workflow-b true

```

Let’s say the last 10 commits to the main branch have been for dir\_a. How can I trigger a build for dir\_b (workflow-b)? The two ways I know are to:

- click “rebuild” on the most recent commit where there was a change in dir\_b, 11 commits ago.
- push a fake change (a blank file or whatever) under dir\_b to the main branch to trigger workflow-b.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![aaronclark](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/aaronclark/32/31078_2.png) [@aaronclark](https://discuss.circleci.com/u/aaronclark)\
**Post date:** [January 18, 2022, 7:05am UTC](https://discuss.circleci.com/t/manually-trigger-path-filtered-workflow/42346/2 "2022-01-18T07:05:50Z")

</div>

Hi @dale.francum,

Thank you for sharing your question on our forum!

When wanting to manually trigger a setup workflow via the API or the “trigger pipeline” button on the dashboard, you will need to add additional pipeline parameters to pass in.

I was not able to get a good working example using just the `path-filtering/filter` job, but I was able to get it to work by using the underlying `continuation/continue` job from the continuation orb. Here are the two sample .yml files:

config.yml

```auto

version: 2.1
setup: true
orbs:
  path-filtering: circleci/path-filtering@0.1.1
  continuation: circleci/continuation@0.2.0
  
parameters:
  manual-workflow-a:
    type: boolean
    default: false 
  manual-workflow-b:
    type: boolean
    default: false
    
workflows:
  setup:
    unless:
      or: [<< pipeline.parameters.manual-workflow-a >>, << pipeline.parameters.manual-workflow-a >>]
    jobs:
      - path-filtering/filter:
          base-revision: << pipeline.git.branch >>
          config-path: .circleci/workflows.yml
          mapping: |
            dir_a/.* run-workflow-a true
            dir_b/.* run-workflow-b true
  setup-manual:
    when: 
      or: [<< pipeline.parameters.manual-workflow-a >>, << pipeline.parameters.manual-workflow-a >>]
    jobs:
      - continuation/continue:
          configuration_path: .circleci/workflows.yml
          parameters: /tmp/pipeline-parameters.json
          pre-steps:
            - run:
                command: |
                  echo '{ "run-workflow-a": << pipeline.parameters.manual-workflow-a >>, "run-workflow-b": << pipeline.parameters.manual-workflow-b >> }' >> /tmp/pipeline-parameters.json

```

workflows.yml (the continuation config)

```auto
version: 2.1

parameters:
  run-workflow-a:
    type: boolean
    default: false 
  run-workflow-b:
    type: boolean
    default: false
  manual-workflow-a:
    type: boolean
    default: false 
  manual-workflow-b:
    type: boolean
    default: false
    
jobs:
  buildjob:
    docker:
      - image: cimg/base:2022.01
    steps:
      - run: echo "test"

workflows:
  workflow-a:
    when: 
      or: [<< pipeline.parameters.run-workflow-a >>, << pipeline.parameters.manual-workflow-a >>]
    jobs:
      - buildjob
  workflow-b:
    when:
      or: [<< pipeline.parameters.run-workflow-b >>, << pipeline.parameters.manual-workflow-b >>]
    jobs:
      - buildjob

```

Essentially I added two pipeline parameters, one for each workflow you would like to manually execute.  
When using the api or the trigger pipeline button, you can pass in `true` or `false` (default `false`) to fire one or multiple workflows.

The path filtering workflow will only run when neither `manual-workflow-a` nor `manual-workflow-b` is true.

If you would like further clarification on anything, please feel free to ask. I hope the above example can serve as a reference for your use case.

Best Regards

---

<div class="post-metadata">

**Author:** ![dale.francum](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@dale.francum](https://discuss.circleci.com/u/dale.francum)\
**Post date:** [January 18, 2022, 2:43pm UTC](https://discuss.circleci.com/t/manually-trigger-path-filtered-workflow/42346/3 "2022-01-18T14:43:12Z")

</div>

Thank you Aaron, this looks promising. I’ll give this a try with our workflows.

Dale

---

<div class="post-metadata">

**Author:** ![dale.francum](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@dale.francum](https://discuss.circleci.com/u/dale.francum)\
**Post date:** [January 18, 2022, 7:49pm UTC](https://discuss.circleci.com/t/manually-trigger-path-filtered-workflow/42346/4 "2022-01-18T19:49:16Z")

</div>

Confirming, this worked well. Thanks @aaronclark !

---

<div class="post-metadata">

**Author:** ![aaronclark](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/aaronclark/32/31078_2.png) [@aaronclark](https://discuss.circleci.com/u/aaronclark)\
**Post date:** [January 19, 2022, 6:50am UTC](https://discuss.circleci.com/t/manually-trigger-path-filtered-workflow/42346/5 "2022-01-19T06:50:57Z")

</div>

@dale.francum Glad to hear it worked!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [January 29, 2022, 6:51am UTC](https://discuss.circleci.com/t/manually-trigger-path-filtered-workflow/42346/6 "2022-01-29T06:51:41Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
