Run step only for new tags

I only want a particular step to be run when there is a tag created for it. I’m not sure of the syntax, I have only seen this being on a per-workflow basis not per-action.

- name: Only do this when tagged
  if: !startsWith(github.ref, 'ref/tags/')
  run: echo "Hello tag ${{ github.ref }}"

I don’t think this is quite the right syntax as github.ref would just be the tag name in this instance.

1 Like

Here is the solution:

- name: Only do this when tagged
  if: startsWith(github.ref, 'refs/tags/')
  run: echo "Hello tag ${{ github.ref }}"
2 Likes