How to trigger action for tag on old commit

So I have a repository, and I want to tag an old version of it (i.e. not the most recent commit).

I have a workflow that is activated when a tag is pushed:

on:
  push:
    tags:
      - 'v*'

I tried creating a new tag in GitHub for a recent version that not the most recent version, and it did not trigger this action. I also tried using git tag v1.0.0 <not-the-most-recent-commit> and pushed it, and it also didn’t get triggered.

Why is that and how can I trigger the action no matter if the tagged commit is the most recent or not?

Hi @dmfrodrigues,

Glad to see you in Github Community Forum!

This is by designed. When you tag old commit and push to repository, github will check if event trigger exists on the workflow yaml “AT THE COMMIT”, while not the latest workflow yaml file.

You can checkout the files based on the old commit, if there’s already tag trigger(on: push: tags) on the workflow yaml, tag on this commit, the workflow will be triggered. If no tag trigger, workflow will not be triggered.

My workflow for your reference.

It’s not supported to always trigger actions no matter old/recent commit is tagged.

Hope it’s clear and helpful!

I see. So the workflow is only triggered if the commit being tagged has the workflow yml file for tags, right?

Please just confirm I understood it right, so I can set it as solution.

Thanks.

Yes, it’s correct!@dmfrodrigues

The github.ref is the updated ref, if you tag on old commit and push to repository, it will check the yaml file till the commit, trigger the workflow if the tag trigger exists.

Thanks.