gha-repo-manager icon indicating copy to clipboard operation
gha-repo-manager copied to clipboard

Don't commit a file if its contents did not change

Open quartz-fm opened this issue 1 year ago • 1 comments

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:

https://github.com/andrewthetechie/gha-repo-manager/blob/e09ab556e261c9f41315a1521e8cb470f6f4e742/repo_manager/github/files.py#L29-L35

I think you already have both files' contents thanks to:

https://github.com/andrewthetechie/gha-repo-manager/blob/e09ab556e261c9f41315a1521e8cb470f6f4e742/repo_manager/github/files.py#L19-L23 and

https://github.com/andrewthetechie/gha-repo-manager/blob/e09ab556e261c9f41315a1521e8cb470f6f4e742/repo_manager/github/files.py#L28

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!

quartz-fm avatar Feb 15 '24 18:02 quartz-fm

Hello,

I'd approve a PR for these changes if someone comes up with a solution.

andrewthetechie avatar Feb 15 '24 18:02 andrewthetechie