I'm trying to check which files have changed previously in a github action. For this I'm running the following command:
git diff --name-only HEAD~1 -- .'
While this works locally, on github actions I seem to get this error:
fatal: bad revision 'HEAD~1'
Checking if any files changed
I'm using the https://github.com/actions/checkout action for doing the checkout.
So I managed to solve it. Apparently the action package I used seems to only fetch the last commit, hence giving the error where it cannot find the other commits when I look for them. The fix was to actually fetch more than one version, this is what I'm doing now in my action, and it works:
...
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 5
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With