Can't trigger workflow on git tag push using when condition

Hi,

I am doing some testing and working on a release pipeline.
At some point in my pipeline, I want to update my package.json, push it and then trigger a next workflow to actually deploy to prod.
To do so I thought to update my package.json in a first workflow which we can call ā€œAā€. At the end, A, will push a tag doing something like:
git tag -a v0.2 -m "my version 0.2" && git push origin v0.2

I would be then expecting it to trigger a next workflow which would take care of the release.
I am aiming to le the workflow trigger on tag push with a syntax like that

on_tag:
    when: << pipeline.git.tag >>
    jobs:
      - build

Using the when conditional on it. But it does not trigger.

Just for testing, I also tried something like

    when: 
      and:
        - equal: [ v0.3, << pipeline.git.tag >> ]
    jobs:
      - build

using equal; but still.

Using a filter, like:

only_on_push_tag: &only_on_push_tag
  filters:
    tags:
      only: /^v0.5.*/
    branches:
      ignore: /.*/

does work.

But I want to stick to the when approach. I can see in the documentation there is some example using the pipeline.tag, even if different.

workflows:
  my-workflow:
    when:
      and:
        - not:
            matches:
              pattern: "^main$"
              value: << pipeline.git.branch >>
        - or:
            - equal: [ canary, << pipeline.git.tag >> ]
            - << pipeline.parameters.deploy-canary >>

So to conclude, any suggestion on how to trigger a workflow on tag push using the when condition? why is not working? Thanks
For now we are not using any package for bumping the package.json, etc.

1 Like

+1

In my case Iā€™m restricted to using workflow conditionals due to the requirements for path-filtering. Filters on jobs do not work in this case as path-filtering requires only a single workflow to be triggered.

Sadly I am also struggling to get the matches or equal logical operator working against the pipeline.git.tag despite following examples & testing:

# staging
  cicd-staging:
    when:
      matches: { pattern: '^v1.0.0-.+$', value: << pipeline.git.tag >> }
    jobs:
      - path-filtering/filter:
          name: 'serverless-cicd'
          base-revision: master
          mapping: |
            dir1/.* dir1-modified true
            dir2/.* dir2-modified true
          config-path: .circleci/serverless-cicd.yml