-
Hello! I need to track the changes being made to the specific list of files inside the repository, let's name them:
The workflow should run when they are changed (in theory it could run always, but when there are no changed files it's better to not run it), and then do something with them. Here's the fragment of the workflow (a bit anonymised): on:
pull_request:
branches:
- main
paths:
- '**/FileA'
- '**/FileB'
- '**/FileC'
jobs:
my-job:
name: My job
runs-on: ubuntu
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
ref: ${{ github.event.pull_request.head.sha }}
- name: Get changed files
id: get-changed-files
uses: tj-actions/[email protected]
with:
json: true
write_output_files: true
since_last_remote_commit: true
files: |
**/FileA
**/FileB
**/FileC
- name: Print all changed and modified files from JSON
run: cat .github/outputs/all_changed_and_modified_files.json
<THE REST OF THE WORKFLOW> It works perfectly as long as somebody didn't change one of these files as a part of the another branch work, then merge those changes to main, and the branch will be updated with the newest main to keep it up to date. Here's the problematic scenario step by step:
I'd like to avoid detecting files NOT modified directly by changes made to the branch by Developer. I noticed that no matter what combination of
In that case the changed files action will compare:
and takes all files changed as a part of Right now it works also perfectly fine with more than 2 commits, as long as they're a part of normal work with branch. How to avoid that? What am doing wrong? Unfortunately I can't provide links to full runs, but if you need some more information or should I do some tests, please let me know. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @ewypych , to prevent this you can change your merge strategy to rebase |
Beta Was this translation helpful? Give feedback.
-
Thanks @jackton1 for your answer! And apologise for such a delay in sending my message. Unfortunately the strategy change is not an option, as Developers merge the base branch to their feature branches locally, with their own git settings so for sure there will be a situation where somebody just forgets to change the default strategy or something like this, so I need to deal with the merge-commit as the default one (and to be quite honest I need to deal with all possible strategies 😅 ). Although I tested
Example for the first point:
|
Beta Was this translation helpful? Give feedback.
Hi @ewypych , to prevent this you can change your merge strategy to rebase
feature/1
with the latest changes inmain
or setsince_last_remote_commit: false