git-auto-commit-action icon indicating copy to clipboard operation
git-auto-commit-action copied to clipboard

Make commit and push into separated optional steps

Open ZeroRin opened this issue 1 year ago • 9 comments

Is your feature request related to a problem? Please describe. I have a repository with two workflows:

  • A scheduled workflow 1 that downloads update data from different sources and create one commit for each source.
  • A on-push workflow 2 that triggers on new data, analyzes the data and create a new commit.

As soon as workflow 1 commits data from first source, it triggers workflow 2. As the two workflows now run in parallel and both may have new commits, further commit from one workflow will be rejected.

Describe the solution you'd like Add an option to disable the commit or push step of this action. As in workflow, the push event may be intentionally used to trigger other workflows, it makes sense to provide more controllable push to me. In my case, I want workflow 1 to create multiple commits without push, and a single push at the end of the workflow.

ZeroRin avatar Sep 04 '22 02:09 ZeroRin

Thanks for the suggestion! This is something we could add to the Action and is something I will consider adding.

The only issue I currently see is in educating users how this feature should be used. For example, users might want to write a single workflow with 3 job steps:

  • Job 1 generates changes and creates a commit
  • Job 2 generates changes and creates a commit
  • Job 3 generates changes, creates a commit and pushes 3 commits to GitHub

This won't work, as the state of each job is independent. Job 1 doesn't know about the state of the git repo in Job 2. The commit would have to be pushed in each job, as it would otherwise get lost forever.


But users who would build such workflows/jobs probably already know, that they have to checkout their repo in each job step.

stefanzweifel avatar Sep 04 '22 09:09 stefanzweifel

Oh, I just noticed that maybe I can achieve this by simply passing push_options: --dry-run to the action

ZeroRin avatar Sep 05 '22 05:09 ZeroRin

push_options: --dry-run sounds like it should do the tricks, at least when running under one job and under one git repo clone. The question is, will the last action invocation that's meant to push indeed attempt to git push even if it didn't create any commits itself (when only the previous ones happened to create any)?

p0358 avatar Sep 30 '22 13:09 p0358

It seems like it does not. The action in case there was nothing to commit shows this output:

Working tree clean. Nothing to commit.

But if git push was invoked, it'd show this, which was not shown:

Everything up-to-date

So properly supporting this might require two new options, one to skip pushing, and one to always attempt pushing... (or just always attempt pushing even if no commit creation was expected?)

p0358 avatar Sep 30 '22 13:09 p0358

You're right. In my own repo I didn't rely on this action for the final push and simply call a run: git push at the end, so I didn't notice this.

ZeroRin avatar Sep 30 '22 16:09 ZeroRin