Closed marcofranssen closed 3 years ago
This should definitely be possible with the current state of the action. 🤔
From you're example, I could find the following issues:
You're setting skip_dirty_check: true
in all your steps. This will bypass the git status
check and will try to create a commit and push to the remote repository.
You're using version v4.4.0
which isn't the latest version. You don't have to use the latest version, but in v4.4.1
the git status
check has been updated to use the given file pattern.
So updating your workflow to use v4.4.1
– or v4
for the latest version – and removing the skip_dirty_check: true
line in your steps should do the trick.
The Action will then only attempt to create a commit and push to the remote repository, if files for the given file pattern actually changed.
jobs:
name: Generate code
steps:
- run: .github/generate.sh
- - uses: stefanzweifel/git-auto-commit-action@v4.4.0
+ - uses: stefanzweifel/git-auto-commit-action@v4.4.1
if: github.ref == 'refs/heads/master'
with:
commit_message: Main changes
commit_options: '--no-verify --signoff'
- skip_dirty_check: true
file_pattern: README.md main/
commit_user_name: My Bot
commit_user_email: mybot@users.noreply.github.com
- - uses: stefanzweifel/git-auto-commit-action@v4.4.0
+ - uses: stefanzweifel/git-auto-commit-action@v4.4.1
if: github.ref == 'refs/heads/master'
with:
commit_message: Update moduleA
commit_options: '--no-verify --signoff'
- skip_dirty_check: true
file_pattern: modules/moduleA
commit_user_name: My Bot
commit_user_email: mybot@users.noreply.github.com
- - uses: stefanzweifel/git-auto-commit-action@v4.4.0
+ - uses: stefanzweifel/git-auto-commit-action@v4.4.1
if: github.ref == 'refs/heads/master'
with:
commit_message: Update moduleB
commit_options: '--no-verify --signoff'
- skip_dirty_check: true
file_pattern: modules/moduleB
commit_user_name: My Bot
commit_user_email: mybot@users.noreply.github.com
However, keep in mind that each step will create a commit and push it to the remote. Between each step you would have to add a git pull
step which updates the local state of the repository in your workflow.
Thanks that did the trick. I have also configured dependabot on my repo for github actions now.
I'm trying to commit multiple commits in my workflow to split the larger amount of changes in smaller commits.
Currently my build is having the following error.
I'm using the following workflow.
As not every module does always have changes, sometimes there is no need to make that commit. Currently the workflow fails because moduleB has changes and moduleA doesn't while trying to commit moduleA.
Am I doing something wrong? Or could this be a feature which would only try to commit if the pattern staged files.