Commit & push only if files updated during action

Hi,

I would like my github action to only do a commit and push if any files are changed during a workflow run.

I have the following block in the action:

    - name: save updated files
      run: |
        git config --global user.email "github-actions[bot]@users.noreply.github.com"
        git config --global user.name "github-actions[bot]"
        git diff-index --quiet HEAD || (git commit -a -m'[bot] update files' && git push -f)

However, this always fails with the error:

Run git config --global user.email "github-actions[bot]@users.noreply.github.com"
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
Error: Process completed with exit code 1.

How can I resolve this? Thanks!

This worked after I changed the command to
git diff-index --quiet HEAD || (git commit -a -m'[bot] update files' --allow-empty && git push -f)