Last active
May 8, 2024 13:00
-
-
Save ryanpedersen42/c867acd9b0837789a92836e8f5bd8b55 to your computer and use it in GitHub Desktop.
Path filtering example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2.1 | |
setup: true | |
orbs: | |
path-filtering: circleci/[email protected] | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Thank god. So easy to read.
Life saver! :)
CircleCI should have such an example, I commented that over there
Thanks!
Quick question, anyone knows how to use different branches with base-revision
on this?
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
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!
Thanks!
Quick question, anyone knows how to use different branches with
base-revision
on this?
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
Thanks for this super simple example!