How to trigger action from release, ignoring specific tags

Hi,

I have two actions, deploy-staging and deploy-production that I want to trigger from releases e.g. “v1.0.0-beta” (for staging) and “v1.0.0” (for production).

I am trying to use the tags.created with a wild card match but both actions always trigger. See below:

deploy-staging:

on:
  release:
    types: created
    tags:
      - 'v*-beta*'

deploy-production:

on:
  release:
    types: created
    tags:
      - '!v*-beta*'

Any idea how best to go about this? This should be simple to do, the docs say to use a “matching negative pattern” which I am but either I’m doing something wrong or it’s broken.

Thanks!
Alex

@alexfoxy,

Tag filters are not evaluated for release event, they are only available to push event and pull_request event. To view more details, you can see here.

As the workaround, you can try using the if conditional to skip the jobs in the workflow.
The github.ref of the workflow run triggered by the release event is the released tag, you can use the job-level if conditional (jobs.<job_id>.if) to skip the jobs in the workflow according to the version of the tag.
For example:

  1. deploy-staging
on:
  release:
    types: [created]
jobs:
  deploy_staging:
    if: ${{ contains(github.ref, '-beta') }}
    . . .
    steps:
      ---- execute steps for deploy_staging ----
  1. deploy-production
on:
  release:
    types: [created]
jobs:
  deploy_production:
    if: ${{ !contains(github.ref, '-beta') }}
    . . .
    steps:
      ---- execute steps for deploy_production ----

Related docs:
Operators
Functions

Of course, if your projects really need the feature that tag filters are also available to release event, I recommend that you can directly report a feature request here. That will allow you to directly interact with the appropriate engineering team, and make it more convenient for the engineering team to collect and categorize your suggestions.

1 Like

Thanks! This works for now :slight_smile: