[GitHub Actions] New workflow, the On event filter for create: tags: <wildcard>

I have two git tag forms v/release/1.0.0 and v/beta/1.0.0 , with following two workflow define:

on:
  create:
    tags:
      - v/release/*

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu

    steps:
      run: npm publish --tag=latest

and

on:
  create:
    tags:
      - v/beta/*

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu

    steps:
      run: npm publish --tag=next

I would expect the two workflows isolated by its tag filters, but seems not, am I doing it wrong?

4 Likes

I’ve been struggling to figure how how to filter by tags as well, but so far as I can tell, wildcarding just doesn’t work at all against tags :scream:

I’ve been trying variations of 

on:
  create:
    tags:
      - v*.*.*-beta.*

Every tag push is triggering all our different environments though, I can’t figure out the right way to do it.

1 Like

It looks like we’re going to have to use the old style bin/filter to get tag filtering work like we’re wanting. It’s just a shame to spin up all those unneccessary instances just to filter against a tag

name: 'deploy:beta'
on:
  create:
    tags:
      - v*.*.*-beta.*
    branches:
      - 'refs/tags/*'
      - '!refs/heads/*'

jobs:
  filter:
    name: 'deploy:beta:filter'
    runs-on: ubuntu-latest
    steps:
      -
        uses: actions/bin/filter@master
        with:
          args: tag v*.*.*-beta.*

  build:
    needs:
      - filter
    name: 'deploy:beta:build'
    runs-on: ubuntu-latest
    steps:
      -
        uses: actions/checkout@v1
        with:
          fetch-depth: 1
...

Hopefully someone else can chime in and explain how to do it better

1 Like

Thanks for reaching out. You should be able to use the push event for tags and filter the way you want. Can you try this and see if it works?

on:
  push:
    tags:
      - v/release/*

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu

    steps:
      run: npm publish --tag=latest

Let us know!

1 Like

Unfortunately it doesn’t work lee-dohm.

It will always triggerd!

I found a way (thanks to this blog post).

Simply use theif configuration.

1 Like

This is a major pain-point right now.

There is no simple way to filter v1.0.0 from v1.0.0-beta0 etc.