I need to detect if the last commit was a revert commit and run some appropriate steps in a GitHub Actions workflow. I'm looking for some appropriate git commands that would help me to detect a git revert.
All the ideas I am seeing suggest to scour through the commit messages looking for the string 'revert' but the commit message might as well be 'abracadabra'.
It would have been nice if git reflog worked inside the runner, but all it does is output a message saying 'switched from master branch to feature'. Are there any options I can use with git log that would indicate that the last commit was actually a revert? My workflow is pretty simple, a bit like the below. What I am looking for are the right commands in the 'Detect revert' step.
steps:
# ...
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Detect revert
run: |
#git reflog # doesn't work
git log ... # are there any options that go here that would help detect a revert?
Any ideas?