Github action nothing to commit, working tree clean

I have a git action, I have to make sure if there is nothing to add then not commit or push. but how can I check if there is something to add and commit if necessary. Here is an example of how I do...