2
0
Fork 0
mirror of https://code.forgejo.org/docker/metadata-action.git synced 2025-08-02 15:58:31 +00:00

Add tag-match-group input to choose group to get if tag-match matches

Check tag-match is a valid regex
This commit is contained in:
CrazyMax 2020-10-27 02:32:26 +01:00
parent ad83daa929
commit 6fe5b3f6bb
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
8 changed files with 74 additions and 16 deletions

View file

@ -41,9 +41,15 @@ export class Meta {
} else if (/^refs\/tags\//.test(this.context.ref)) {
version.version = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
if (this.inputs.tagMatch) {
const tagMatch = version.version.match(this.inputs.tagMatch);
let tagMatch;
const isRegEx = this.inputs.tagMatch.match(/^\/(.+)\/(.*)$/);
if (isRegEx) {
tagMatch = version.version.match(new RegExp(isRegEx[1], isRegEx[2]));
} else {
tagMatch = version.version.match(this.inputs.tagMatch);
}
if (tagMatch) {
version.version = tagMatch[0];
version.version = tagMatch[this.inputs.tagMatchGroup];
version.latest = this.inputs.tagMatchLatest;
}
}