0

I want to print the current git Tag's message in a Github Action.

If I run the following locally:

git tag -l --sort=-taggerdate --format='%(contents)' $(git describe --tags $(git branch --show-current) )

It prints the tag msg:

v1.1.1-155

* Bug fixes

However when running the Github Action, it prints the latest commit's message.

How can I make Github Actions print the tag and not the commit?


The build.yml trigger for the Action is:

on:
  push:
    tags:
      - '*'
Simon
  • 11
  • 2
  • Do you want only the latest tag to be printed? If yes, [this gist](https://gist.github.com/rponte/fdc0724dd984088606b0) could maybe help you get what you want. – GuiFalourd May 11 '22 at 12:42
  • @GuiFalourd The gist only prints the tag, and not the annotaded tag message. – Simon May 11 '22 at 13:18
  • In that case, would [that thread](https://stackoverflow.com/questions/21561789/print-the-message-of-a-git-tag) answer your question? – GuiFalourd May 11 '22 at 13:26

1 Answers1

1

The solution is to fetch all tags apparently:

- name: Fetch Tags
  run: git fetch --tags --force
Simon
  • 11
  • 2