Trigger with release event and specific tag

I want my workflow to be triggered when a release is published and has a specific tag syntax. So, I wrote the following:

    types: [published]
      - v[0-9]+.*'

However, the workflow is triggered when a release is published, regardless of its tag name.

Is it possible to configure the filtering the way I want?

The release event doesn’t support filtering by tag name according to the docs. Only push and pull_request do:

You could add an if conditional to your jobs to skip them if the tag isn’t right. There will still be a workflow run however. It’s also non-trivial to do this since the the tag name pattern is a regular expressions but there is no workflow expression function to evaluate one. It should be possible to add a job that all other jobs depend on (needs), use it to validate the tag and set the result as job output.

The tag name should be accessible via ${{ github.event.release.tag_name }}. You’ll need some shell code or github-script to evaluate the regular expression against the tag name.

1 Like

@Simran-B thanks for the reply. I was hoping that filtering is added at the trigger level so that the workflow doesn’t even start.

I ended up using the if conditional this way:

 if:  ${{ startsWith(github.event.release.tag_name, 'some name') }}
1 Like