Skip to content

Instantly share code, notes, and snippets.

@ryanpedersen42
Last active May 8, 2024 13:00
Show Gist options
  • Save ryanpedersen42/c867acd9b0837789a92836e8f5bd8b55 to your computer and use it in GitHub Desktop.
Save ryanpedersen42/c867acd9b0837789a92836e8f5bd8b55 to your computer and use it in GitHub Desktop.
Path filtering example
version: 2.1
setup: true
orbs:
path-filtering: circleci/path-filtering@0.0.2
workflows:
setup-workflow:
jobs:
- path-filtering/filter:
base-revision: main
config-path: .circleci/continue-config.yml
mapping: |
project1/.* project-one true
project2/.* project-two true
project3/.* project-three true
shared-things/.* run-them-all true
version: 2.1
executors:
base:
docker:
- image: cimg/base:stable
parameters:
project-one:
type: boolean
default: false
project-two:
type: boolean
default: false
project-three:
type: boolean
default: false
run-them-all:
type: boolean
default: false
jobs:
project_one:
executor: base
steps:
- run:
command: |
echo "project one"
project_two:
executor: base
steps:
- run:
command: |
echo "project two"
project_three:
executor: base
steps:
- run:
command: |
echo "project three"
all_projects:
executor: base
steps:
- run:
command: |
echo "all"
workflows:
build-1:
when:
or:
- << pipeline.parameters.project-one >>
- << pipeline.parameters.run-them-all >>
jobs:
- project_one
build-2:
when:
or:
- << pipeline.parameters.project-two >>
- << pipeline.parameters.run-them-all >>
jobs:
- project_two
build-3:
when:
or:
- << pipeline.parameters.project-three >>
- << pipeline.parameters.run-them-all >>
jobs:
- project_three
build-shared-other:
when: << pipeline.parameters.run-them-all >>
jobs:
- all_projects
@jghiloni
Copy link

what happens if i have two paths for one variable? will it set the variable if either path is modified? e.g.

            project1/.* project-one true 
            shared-things/.* project-one true

Yes!

@snooky23
Copy link

Thanks!

Quick question, anyone knows how to use different branches with base-revision on this?

@ryanpedersen42

use base-revision for different actions based on branch.
you can only specify only one branch per job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment