git rev-list not working inside github action

Viewed 731

I have a github action that is triggered when a release is created.

The goal is to:

  • Find the tag on which the release was based
  • Find the previous tag on that branch

So far, I have this:

CURRENT_TAG=${{ github.event.release.tag_name }}
PENULTIMATE_TAG=$(git describe --exact-match --tags `git rev-list --tags --max-count=1 --skip=1`)

These are then echoed out for testing. The first works correctly, but the second always returns empty. I have tried the exact same command locally, and it returns the second most recent tag, as expected.

I have no idea why it wouldn't work in a github action. For the sake of debugging, I removed the git describe component, confirming that it is in fact git rev-list that is returning nothing.

1 Answers

Need to fetch all history by passing the fetch-depth option:

 - uses: actions/checkout@v2
      with:
        fetch-depth: 0
Related