According to the github action documentation, it should work in the same workflow using multiple paths.
If you also use the paths-filter action you can get to the result you want with something like this:
Example:
name: Trigger Jenkins Build [ Build-Portal ]
on:
push:
branches: [ develop ]
paths:
- 'frontend/**'
- 'backend/**'
types: [closed]
jobs:
build:
name: Triggering Jenkins Build [ Build-Portal ]
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
backend:
- 'backend/**'
frontend:
- 'frontend/**'
- name: Trigger Build-Portal FRONTEND
# run only if some file in 'frontend' folder was changed
if: steps.changes.outputs.frontend == 'true'
uses: actions/trigger-jenkins@develop
with:
...
job_name: "Build-Portal"
job_params: '{"FRESH_BUILD":"True", "UI":"True", "BUILD_BRANCH":"develop", "DEPLOY_DEV":"True"}'
...
- name: Trigger Build-Portal BACKEND
# run only if some file not 'backend' folder was changed
if: steps.changes.outputs.backend == 'true'
uses: actions/trigger-jenkins@develop
with:
...
job_name: "Build-Portal"
job_params: '{"FRESH_BUILD":"True", "API":"True", "BUILD_BRANCH":"develop", "DEPLOY_DEV":"True"}'
...
Answer from GuiFalourd on Stack OverflowAccording to the github action documentation, it should work in the same workflow using multiple paths.
If you also use the paths-filter action you can get to the result you want with something like this:
Example:
name: Trigger Jenkins Build [ Build-Portal ]
on:
push:
branches: [ develop ]
paths:
- 'frontend/**'
- 'backend/**'
types: [closed]
jobs:
build:
name: Triggering Jenkins Build [ Build-Portal ]
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
backend:
- 'backend/**'
frontend:
- 'frontend/**'
- name: Trigger Build-Portal FRONTEND
# run only if some file in 'frontend' folder was changed
if: steps.changes.outputs.frontend == 'true'
uses: actions/trigger-jenkins@develop
with:
...
job_name: "Build-Portal"
job_params: '{"FRESH_BUILD":"True", "UI":"True", "BUILD_BRANCH":"develop", "DEPLOY_DEV":"True"}'
...
- name: Trigger Build-Portal BACKEND
# run only if some file not 'backend' folder was changed
if: steps.changes.outputs.backend == 'true'
uses: actions/trigger-jenkins@develop
with:
...
job_name: "Build-Portal"
job_params: '{"FRESH_BUILD":"True", "API":"True", "BUILD_BRANCH":"develop", "DEPLOY_DEV":"True"}'
...
I don't see the reason behind this complexity. Just use 2 YML files
frontend.yml => this is where you put path condition to match frontend path
on:
push:
branches: [ develop ]
paths:
- 'frontend/**'
backend.yml => this is where you put path condition to match backend path
on:
push:
branches: [ develop ]
paths:
- 'backend/**'
Both files will be evaluated everytime a push is done and GH will decide which flow to run.
You can always use a default yml file to run anyway whenever any change occurs outside these paths
How does on.paths really work?
How to define a trigger for such GitHub Action based on branch and path?
Path to action in the same repository as workflow
What’s the best way to trigger a GitHub Actions workflow only when specific files or folders change?
Videos
I would like my script to run with PR when any of these conditions is true
the file is changed inside samples/starter-projects/ OR branch name starting with the "release" OR branch name starting with the "renovate"