On a push to any file within the src/** directory, this workflow will execute job1 and its steps.
Run job based on file changes in GitHub Actions
GitHub actions do not natively support triggering jobs based on file changes; however, there is a marketplace action that supports this use-case named dorny/paths-filter.
On a push to the main branch, this workflow will execute; however, the first action checks where changes occurred and outputs true or false for the specified filtered paths.
Run step based on file changes in GitHub Actions
Similarly to jobs, GitHub actions to not natively support triggering individual steps based on file changes. dorny/paths-filter supports this use-case as well.
On a side note, dorny/paths-filter does not need the checkout action for pull request triggered actions.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
on:pull_request:branches:- mainjobs:build:runs-on:ubuntu-latest# For pull requests, it's not necessary to checkout codepermissions:pull-requests:readsteps:- uses:dorny/paths-filter@v2id:filterwith:filters:...# Configure your filters