Search code examples
tagsgithub-actions

Why doesn't my github action trigger on a regex tag


For my first attempt at Github Actions I need to trigger based on a git tag such as 1.2.3-RELEASE, which seems like a common enough thing. I can find examples like this:

on:
  push:
    tags:        
      - v1             # Push events to v1 tag
      - v1.*           # Push events to v1.0, v1.1, and v1.9 tags

so I created my yaml file like this:

on:
  push:
    tags: 
      - '[1-9]+.[0-9]+.[0-9]+\-RELEASE'

But it never fires. I verified the regex expression with an online tool and I tried a tag v1.1 with it set up with the first example, and that worked with or without quotes. My expression needs quotes, which is fine, but it doesn't work. Anyone know what I'm doing wrong here?


Solution

  • The GitHub Action syntax doc does mention:

    The branches, branches-ignore, tags, and tags-ignore keywords accept glob patterns that use the * and ** wildcard characters to match more than one branch or tag name.
    For more information, see the "Filter pattern cheat sheet".

    So a normal regex would not work.
    Your expression is close enough of a glob pattern: I would try and not escape the -:

    [1-9]+.[0-9]+.[0-9]+-RELEASE