-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Is your feature request related to a problem? Please describe.
I noticed that a commit is pushed to the target repo when pushing a file to a repository, even when the file has no changes. This triggers unnecessary CI runs due to the commit. As each file is committed individually, it makes things even worse by triggering multiple CI runs in parallel.
Describe the solution you'd like
Nothing should happen if a file has no changes.
Describe alternatives you've considered
Use many workflows/jobs/settings with filtering logic to trigger only on change— which is better solved by using other file sync actions.
Additional context
I think the GitHub REST API makes a commit, regardless of whether the file contents changed, when you invoke it here:
gha-repo-manager/repo_manager/github/files.py
Lines 29 to 35 in e09ab55
result = repo.update_file( | |
str(file_config.dest_file.relative_to(".")), | |
file_config.commit_msg, | |
file_contents, | |
sha=dest_contents.sha, | |
branch=target_branch, | |
) |
I think you already have both files' contents thanks to:
gha-repo-manager/repo_manager/github/files.py
Lines 19 to 23 in e09ab55
file_contents = ( | |
file_config.src_file_contents | |
if not file_config.remote_src | |
else get_remote_file_contents(repo, file_config.src_file, target_branch) | |
) |
and
dest_contents = repo.get_contents(str(file_config.dest_file), ref=target_branch) |
Could a SHA or contents comparison be added? I don't know Python or the GitHub API, so I did my best to investigate, but I can't do more on my side. Thanks!