I have a CI/CD pipeline in GitHub Actions that runs and one of the steps is to commit to another repository. What it does is that it clones to external repository, moves files into it, and then commits it back to the external repository.
The thing is, there is no grantee that there will be a new file to commit.
When that happens, the repository fails because Git throws an error as shown
How can I get around that?
You could use the
git status --porcelain command (reference 1 + reference 2) to check if some changes occurred.
It could look like this using
run: if [[ `git status --porcelain` ]]; then echo "OK: Changes detected." else echo "WARNING: No changes were detected." fi shell: bash
Obs: I’m using it in a action to git commit push changes.
Answered By – GuiFalourd
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0