fjogeleit / yaml-update-action

Update YAML property with dynamic values
MIT License
143 stars 45 forks source link

Empty commits on open PR #549

Open nagano opened 1 year ago

nagano commented 1 year ago

After opening a PR with the changes, if I run the action again it pushes an empty commit to the branch. Is there any way to avoid this?

I have a workflow that runs a couple times a week and the PR can remain open for a while, and I'd like to avoid the noise.

fjogeleit commented 1 year ago

Your first run creates a branch and opens a PR, the second run pushes an empty commit to the already created branch?

nagano commented 1 year ago

Correct. After the first run, it pushes a commit with no content on the next runs

fjogeleit commented 1 year ago

The action would stop if the content would not change but in your case its not possible.

If you create branches for your changes, you could check in a step before if a branch already exists and stop if so.

git ls-remote --exit-code --heads origin <branch-name>
nagano commented 1 year ago

Is the problem related to creating a branch + pushing the changes?

In my case, there could be changes between the first run (create branch + open PR) and the next time it runs the action, since the YAML values are based on a separate config file. So I need to run the action every time to check for new changes, I can't stop the whole thing based on the existence of the branch.

Also, forgot to mention, but my workflow is targeting a different target repo

fjogeleit commented 1 year ago

Hmm okay, I can check if I find a possible check to avoid it but not sure if I can do much against it.