Skip to content

Commit d96da8a

Browse files
committed
Prefix/suffix not taken into account
1 parent f39f06a commit d96da8a

File tree

3 files changed

+126
-35
lines changed

3 files changed

+126
-35
lines changed

__tests__/meta.test.ts

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,72 @@ describe('pr', () => {
15781578
"org.opencontainers.image.licenses=MIT"
15791579
]
15801580
],
1581+
[
1582+
'pr05',
1583+
'event_pull_request.env',
1584+
{
1585+
images: ['org/app', 'ghcr.io/user/app'],
1586+
tags: [
1587+
`type=ref,event=pr`
1588+
],
1589+
flavor: [
1590+
`prefix=glo-`,
1591+
`suffix=-bal`
1592+
]
1593+
} as Inputs,
1594+
{
1595+
main: 'pr-2-bal',
1596+
partial: [],
1597+
latest: false
1598+
} as Version,
1599+
[
1600+
'org/app:pr-2-bal',
1601+
'ghcr.io/user/app:pr-2-bal'
1602+
],
1603+
[
1604+
"org.opencontainers.image.title=Hello-World",
1605+
"org.opencontainers.image.description=This your first repo!",
1606+
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
1607+
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
1608+
"org.opencontainers.image.version=pr-2-bal",
1609+
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
1610+
"org.opencontainers.image.revision=1e9249f05bfc090e0688b8fb9c1b347586add504",
1611+
"org.opencontainers.image.licenses=MIT"
1612+
]
1613+
],
1614+
[
1615+
'pr06',
1616+
'event_pull_request.env',
1617+
{
1618+
images: ['org/app', 'ghcr.io/user/app'],
1619+
tags: [
1620+
`type=ref,event=pr,prefix=`
1621+
],
1622+
flavor: [
1623+
`prefix=glo-`,
1624+
`suffix=-bal`
1625+
]
1626+
} as Inputs,
1627+
{
1628+
main: 'glo-2-bal',
1629+
partial: [],
1630+
latest: false
1631+
} as Version,
1632+
[
1633+
'org/app:glo-2-bal',
1634+
'ghcr.io/user/app:glo-2-bal'
1635+
],
1636+
[
1637+
"org.opencontainers.image.title=Hello-World",
1638+
"org.opencontainers.image.description=This your first repo!",
1639+
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
1640+
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
1641+
"org.opencontainers.image.version=glo-2-bal",
1642+
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
1643+
"org.opencontainers.image.revision=1e9249f05bfc090e0688b8fb9c1b347586add504",
1644+
"org.opencontainers.image.licenses=MIT"
1645+
]
1646+
]
15811647
])('given %p with %p event', tagsLabelsTest);
15821648
});
15831649

@@ -1758,6 +1824,39 @@ describe('schedule', () => {
17581824
"org.opencontainers.image.licenses=MIT"
17591825
]
17601826
],
1827+
[
1828+
'schedule07',
1829+
'event_schedule.env',
1830+
{
1831+
images: ['org/app', 'ghcr.io/user/app'],
1832+
tags: [
1833+
`type=schedule`,
1834+
],
1835+
flavor: [
1836+
`prefix=glo-`,
1837+
`suffix=-bal`
1838+
]
1839+
} as Inputs,
1840+
{
1841+
main: 'glo-nightly-bal',
1842+
partial: [],
1843+
latest: false
1844+
} as Version,
1845+
[
1846+
'org/app:glo-nightly-bal',
1847+
'ghcr.io/user/app:glo-nightly-bal'
1848+
],
1849+
[
1850+
"org.opencontainers.image.title=Hello-World",
1851+
"org.opencontainers.image.description=This your first repo!",
1852+
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
1853+
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
1854+
"org.opencontainers.image.version=glo-nightly-bal",
1855+
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
1856+
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
1857+
"org.opencontainers.image.licenses=MIT"
1858+
]
1859+
],
17611860
])('given %p with %p event', tagsLabelsTest);
17621861
});
17631862

dist/index.js

Lines changed: 11 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/meta.ts

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,14 @@ export class Meta {
9999
}
100100

101101
const currentDate = this.date;
102-
const vraw = handlebars.compile(tag.attrs['pattern'])({
103-
date: function (format) {
104-
return moment(currentDate).utc().format(format);
105-
}
106-
});
102+
const vraw = this.setFlavor(
103+
handlebars.compile(tag.attrs['pattern'])({
104+
date: function (format) {
105+
return moment(currentDate).utc().format(format);
106+
}
107+
}),
108+
tag
109+
);
107110

108111
if (version.main == undefined) {
109112
version.main = vraw;
@@ -138,21 +141,16 @@ export class Meta {
138141
includePrerelease: true
139142
});
140143
if (semver.prerelease(vraw)) {
141-
vraw = handlebars.compile('{{version}}')(sver);
142-
if (version.main == undefined) {
143-
version.main = vraw;
144-
} else if (vraw !== version.main) {
145-
version.partial.push(vraw);
146-
}
144+
vraw = this.setFlavor(handlebars.compile('{{version}}')(sver), tag);
147145
} else {
148-
vraw = handlebars.compile(tag.attrs['pattern'])(sver);
149-
if (version.main == undefined) {
150-
version.main = vraw;
151-
} else if (vraw !== version.main) {
152-
version.partial.push(vraw);
153-
}
146+
vraw = this.setFlavor(handlebars.compile(tag.attrs['pattern'])(sver), tag);
154147
latest = true;
155148
}
149+
if (version.main == undefined) {
150+
version.main = vraw;
151+
} else if (vraw !== version.main) {
152+
version.partial.push(vraw);
153+
}
156154
if (version.latest == undefined) {
157155
version.latest = this.flavor.latest == 'auto' ? latest : this.flavor.latest == 'true';
158156
}
@@ -189,7 +187,7 @@ export class Meta {
189187
return version;
190188
}
191189

192-
vraw = tmatch[tag.attrs['group']];
190+
vraw = this.setFlavor(tmatch[tag.attrs['group']], tag);
193191
latest = true;
194192

195193
if (version.main == undefined) {

0 commit comments

Comments
 (0)