Is there a more elegant/shorter way to run workflows on tag push?

It seems that the only way to have the workflow run when a tag is pushed is to add:

filters:
  tags:
    only: /.*/

To every job. As in:

workflows:
  build:
    jobs:
      - build-linux:
          filters:
            tags:
              only: /.*/
          name: 'Linux arm64v8'
          image_tag: 'linux-arm64v8'
          arch: 'arm64'
      - build-linux:
          filters:
            tags:
              only: /.*/
          name: 'Linux arm32v7'
          image_tag: 'linux-arm32v7'
          arch: 'arm32v7'
      - build-linux:
          filters:
            tags:
              only: /.*/
          name: 'Linux x86'
          image_tag: 'linux-x86'
          arch: 'x86'
      - build-linux:
          filters:
            tags:
              only: /.*/
          name: 'Linux x64'
          image_tag: 'linux-x86_64'
          arch: 'x86_64'

Is there a way that doesn’t involve copy paste repetition?

Edit:
The reason I need this is so that I can upload a release if the push was a tag. So in the release-upload job, I check if the push is a tag using a condition. But for that to happen, the workflow has to actually run, and without all these filters, nothing runs. If there’s a better way to do this, I’m all ears :slight_smile:

Hi @RealNC,

You can try using anchors and aliases for a more eloquent looking config.yml. Can you give that a try and let me know how it goes?

Alternatively, you could create an orb that handles tag filtering. You can also create an orb to avoid repetition.

I hope that answers your question. Please let me know how it goes.

Thank you!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.