You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I need to track the changes being made to the specific list of files inside the repository, let's name them:
FileA
FileB
FileC
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:
- mainpaths:
- '**/FileA'
- '**/FileB'
- '**/FileC'jobs:
my-job:
name: My jobruns-on: ubuntusteps:
- uses: actions/checkout@v4with:
fetch-depth: 2ref: ${{ github.event.pull_request.head.sha }}
- name: Get changed filesid: get-changed-filesuses: tj-actions/[email protected]with:
json: truewrite_output_files: truesince_last_remote_commit: truefiles: | **/FileA **/FileB **/FileC
- name: Print all changed and modified files from JSONrun: 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:
The branch feature/1 is created.
The changes has been made to FileA.
Pull Request feature/1 -> main is created, workflows detects the change in FileA (NO MERGING!).
The new branch feature/2 is created off main.
The file FileB is changed in `feature/2.
Pull Request feature/2 -> main is created, workflows detects the change in FileB.
PR feature/2 -> main is merged.
The feature branch feature/1 is updated to latest main.
Some changes are made to feature/1 and pushed along with the merging commit to already opened PR.
The workflow in PR feature/1 -> main detect change in FileB coming from the completely different change.
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 checkout action I use (fetch-deep set to 0, 1, 2, ref like in the code above, or empty) the changed-files action tries to compare the latest commit with the commit BEFORE the merging main into the branch, like here:
some commit messages d9e6784
Merge main into feature 4e90dc32
another commit 67ac78a
In that case the changed files action will compare:
Retrieving changes between d9e6784 (feature/1) → 67ac78a (feature1)
and takes all files changed as a part of 4e90dc32. Of course it's the merging commit, made by git merge main or GitHub UI/IDE equivalent.
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.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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):
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:
feature/1
is created.FileA
.feature/1
->main
is created, workflows detects the change inFileA
(NO MERGING!).feature/2
is created offmain
.FileB
is changed in `feature/2.feature/2
->main
is created, workflows detects the change inFileB
.feature/2
->main
is merged.feature/1
is updated to latest main.feature/1
and pushed along with the merging commit to already opened PR.feature/1
->main
detect change inFileB
coming from the completely different change.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
checkout
action I use (fetch-deep
set to 0, 1, 2,ref
like in the code above, or empty) thechanged-files
action tries to compare the latest commit with the commit BEFORE the merging main into the branch, like here:In that case the changed files action will compare:
and takes all files changed as a part of
4e90dc32
. Of course it's the merging commit, made bygit merge main
or GitHub UI/IDE equivalent.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.
All reactions