This week at $CURRENT_JOB I was tasked to write a GitHub Actions workflow that would update our buf.build lockfile and open a PR with the new version.
At first it seemed very simple, but I have to relearn Bash every time I write it. Fortunately, the solution was easier than we thought after some trial and errors:
if [ -z "$(git status --porcelain)" ]; then
echo "no changes were found"
# exits the pipeline without failing
exit 0
else
echo "changes were found"
# do something with the changes
fi