Reputation: 3880
How to apply branches-ignore
and paths-ignore
on GitHub Actions? For example, if I have the following source tree:
|-src\
|----reports\
|-------<foo>DailyReports.ts
I want to only deploy that to production (master
branch) but NOT staging (staging
branch).
Any advice and insight is appreciated.
Upvotes: 1
Views: 3617
Reputation: 22970
You won't be able to achieve what you want with ON
trigger configuration alone. Therefore the implementation below wouldn't work as it would trigger for push to the specified path OR
for push to the master branch, but not only for both:
on:
push:
path:
- 'src/reports/*DailyReports.ts'
branches:
- master
In that case, you could do it by using only one trigger at the workflow level, and check the other condition with an IF
expression.
For example by doing this:
on:
push:
path:
- 'src/reports/*DailyReports.ts'
jobs:
job1:
runs-on: ...
if: github.ref == 'refs/heads/master' # run this job only for the master branch
steps:
...
Or by checking the branch at the workflow level, and then use something like this path-filter action to check if the file or directory has been updated or not before performing some operation.
I personally suggest the first option (cf example), as it's less verbose.
Note: If the src/reports/*DailyReports.ts
path isn't working as expected, you can use the filter pattern cheat sheet to find the right expression.
Upvotes: 2