metadata-action icon indicating copy to clipboard operation
metadata-action copied to clipboard

Get multiple groups from type=match

Open JoshLoecker opened this issue 2 years ago • 1 comments

Behaviour

I would like to select discontinuous portions of a tag, but it isn't possible using only regex

Steps to reproduce this issue

  1. Using this regex101 as an example: https://regex101.com/r/5pNbil/1
  2. We can see there is an example tag being used (v0.1.27-master)
  3. Assuming this is being used with type=match,pattern=(v\d\.\d)(?:\.\d{1,2})(-\w+), two capturing groups are created.
  4. It is not possible to "merge" these captured groups in regex, it must be done in code

Expected behaviour

I would like to be able to specify multiple group values

Actual behaviour

I am only able to select a single value, as commas are seen as separators

Note

I would like to do this to be able to create an over-arching "version" encompassing all updates under version 0.1, 0.2, etc. for the master, testing, etc. branches in Docker Hub

This may be able to be done currently, but I could not find anything documented.

Thanks for any help!

JoshLoecker avatar Aug 23 '22 21:08 JoshLoecker

If the above isn't possible, I can simply switch the order of my tags. Instead of vX.Y.Z-BRANCH, I can do BRANCH-X.Y.Z and use the following regex: ^\w+-\d+\.\d+. This will let me match the branch name at the front of the tag, followed by a digit, period, digit.

JoshLoecker avatar Aug 23 '22 22:08 JoshLoecker

What do you want to capture exactly? v0.1.27 and v0.1? If that's the case you can define as many match pattern as you want and set the right group to capture as show in the README: https://github.com/docker/metadata-action#typematch

Using this regex101 as an example: https://regex101.com/r/5pNbil/1

Looking at your example it doesn't seem your regex is correct and doesn't match what you expect:

image

I guess you want smth like this:

tags: |
  # v0.1.27
  type=match,pattern=v\d+.\d+.\d+
  # v0.1
  type=match,pattern=v\d+.\d+

crazy-max avatar Oct 07 '22 20:10 crazy-max