If you take a look at the documentation for the actions/checkout@v2 action, you'll see it performs a shallow clone with a single revision by default:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
# Default: 1
fetch-depth: ''
Because it only fetches a single revision, there is no HEAD^
.
You can fix this by setting the fetch-depth
option on the checkout action. Setting it to 0
will fetch the entire history; alternatively, for what you're doing you could probably just set it to 2
:
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 2
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…