3
0
Fork 0
mirror of https://gitea.com/docker/metadata-action.git synced 2024-11-21 19:49:32 +01:00

increase short commit hash length to 12 for uniqueness

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2024-10-31 10:11:17 +01:00
parent d31acd5065
commit bb9c6dd583
No known key found for this signature in database
GPG key ID: ADE44D8C9D44FBE4
3 changed files with 67 additions and 66 deletions

View file

@ -722,7 +722,8 @@ tags: |
type=sha,format=long type=sha,format=long
``` ```
Output Git short commit (or long if specified) as Docker tag like `sha-ad132f5`. Output Git short commit (or long if specified) as Docker tag like
`sha-860c1904a1ce`.
Extended attributes and default values: Extended attributes and default values:

View file

@ -310,14 +310,14 @@ describe('push', () => {
} as Inputs, } as Inputs,
{ {
main: 'dev', main: 'dev',
partial: ['sha-860c190'], partial: ['sha-860c1904a1ce'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:dev', 'org/app:dev',
'org/app:sha-860c190', 'org/app:sha-860c1904a1ce',
'ghcr.io/user/app:dev', 'ghcr.io/user/app:dev',
'ghcr.io/user/app:sha-860c190' 'ghcr.io/user/app:sha-860c1904a1ce'
], ],
[ [
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -343,14 +343,14 @@ describe('push', () => {
} as Inputs, } as Inputs,
{ {
main: 'edge', main: 'edge',
partial: ['sha-2665741'], partial: ['sha-266574110acf'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:edge', 'org/app:edge',
'org/app:sha-2665741', 'org/app:sha-266574110acf',
'ghcr.io/user/app:edge', 'ghcr.io/user/app:edge',
'ghcr.io/user/app:sha-2665741' 'ghcr.io/user/app:sha-266574110acf'
], ],
[ [
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -376,14 +376,14 @@ describe('push', () => {
} as Inputs, } as Inputs,
{ {
main: 'edge', main: 'edge',
partial: ['sha-860c190'], partial: ['sha-860c1904a1ce'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:edge', 'org/app:edge',
'org/app:sha-860c190', 'org/app:sha-860c1904a1ce',
'ghcr.io/user/app:edge', 'ghcr.io/user/app:edge',
'ghcr.io/user/app:sha-860c190' 'ghcr.io/user/app:sha-860c1904a1ce'
], ],
[ [
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -408,13 +408,13 @@ describe('push', () => {
], ],
} as Inputs, } as Inputs,
{ {
main: 'sha-2665741', main: 'sha-266574110acf',
partial: [], partial: [],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:sha-2665741', 'org/app:sha-266574110acf',
'ghcr.io/user/app:sha-2665741' 'ghcr.io/user/app:sha-266574110acf'
], ],
[ [
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -424,7 +424,7 @@ describe('push', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-2665741" "org.opencontainers.image.version=sha-266574110acf"
], ],
undefined undefined
], ],
@ -439,13 +439,13 @@ describe('push', () => {
], ],
} as Inputs, } as Inputs,
{ {
main: 'sha-983315b', main: 'sha-983315b5e8d4',
partial: [], partial: [],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:sha-983315b', 'org/app:sha-983315b5e8d4',
'ghcr.io/user/app:sha-983315b' 'ghcr.io/user/app:sha-983315b5e8d4'
], ],
[ [
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -455,7 +455,7 @@ describe('push', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-983315b" "org.opencontainers.image.version=sha-983315b5e8d4"
], ],
undefined undefined
], ],
@ -1341,17 +1341,17 @@ describe('tag', () => {
} as Inputs, } as Inputs,
{ {
main: '1.0.0', main: '1.0.0',
partial: ['1.0', 'sha-860c190'], partial: ['1.0', 'sha-860c1904a1ce'],
latest: true latest: true
} as Version, } as Version,
[ [
'org/app:1.0.0', 'org/app:1.0.0',
'org/app:1.0', 'org/app:1.0',
'org/app:sha-860c190', 'org/app:sha-860c1904a1ce',
'org/app:latest', 'org/app:latest',
'ghcr.io/user/app:1.0.0', 'ghcr.io/user/app:1.0.0',
'ghcr.io/user/app:1.0', 'ghcr.io/user/app:1.0',
'ghcr.io/user/app:sha-860c190', 'ghcr.io/user/app:sha-860c1904a1ce',
'ghcr.io/user/app:latest' 'ghcr.io/user/app:latest'
], ],
[ [
@ -1381,17 +1381,17 @@ describe('tag', () => {
} as Inputs, } as Inputs,
{ {
main: '1.0.0', main: '1.0.0',
partial: ['1.0', 'sha-860c190'], partial: ['1.0', 'sha-860c1904a1ce'],
latest: true latest: true
} as Version, } as Version,
[ [
'org/app:1.0.0', 'org/app:1.0.0',
'org/app:1.0', 'org/app:1.0',
'org/app:sha-860c190', 'org/app:sha-860c1904a1ce',
'org/app:latest', 'org/app:latest',
'ghcr.io/user/app:1.0.0', 'ghcr.io/user/app:1.0.0',
'ghcr.io/user/app:1.0', 'ghcr.io/user/app:1.0',
'ghcr.io/user/app:sha-860c190', 'ghcr.io/user/app:sha-860c1904a1ce',
'ghcr.io/user/app:latest' 'ghcr.io/user/app:latest'
], ],
[ [
@ -1423,17 +1423,17 @@ describe('tag', () => {
} as Inputs, } as Inputs,
{ {
main: '1.0.0-dev', main: '1.0.0-dev',
partial: ['1.0', 'sha-860c190-dev'], partial: ['1.0', 'sha-860c1904a1ce-dev'],
latest: true latest: true
} as Version, } as Version,
[ [
'org/app:1.0.0-dev', 'org/app:1.0.0-dev',
'org/app:1.0', 'org/app:1.0',
'org/app:sha-860c190-dev', 'org/app:sha-860c1904a1ce-dev',
'org/app:latest', 'org/app:latest',
'ghcr.io/user/app:1.0.0-dev', 'ghcr.io/user/app:1.0.0-dev',
'ghcr.io/user/app:1.0', 'ghcr.io/user/app:1.0',
'ghcr.io/user/app:sha-860c190-dev', 'ghcr.io/user/app:sha-860c1904a1ce-dev',
'ghcr.io/user/app:latest' 'ghcr.io/user/app:latest'
], ],
[ [
@ -1460,16 +1460,16 @@ describe('tag', () => {
] ]
} as Inputs, } as Inputs,
{ {
main: 'v1.1.1-860c190-foo', main: 'v1.1.1-860c1904a1ce-foo',
partial: [ partial: [
'master-foo' 'master-foo'
], ],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:v1.1.1-860c190-foo', 'org/app:v1.1.1-860c1904a1ce-foo',
'org/app:master-foo', 'org/app:master-foo',
'ghcr.io/user/app:v1.1.1-860c190-foo', 'ghcr.io/user/app:v1.1.1-860c1904a1ce-foo',
'ghcr.io/user/app:master-foo' 'ghcr.io/user/app:master-foo'
], ],
[ [
@ -1480,7 +1480,7 @@ describe('tag', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=v1.1.1-860c190-foo" "org.opencontainers.image.version=v1.1.1-860c1904a1ce-foo"
], ],
undefined undefined
], ],
@ -2334,14 +2334,14 @@ describe('pr', () => {
} as Inputs, } as Inputs,
{ {
main: 'pr-15', main: 'pr-15',
partial: ['sha-a9c8c58'], partial: ['sha-a9c8c5828b91'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:pr-15', 'org/app:pr-15',
'org/app:sha-a9c8c58', 'org/app:sha-a9c8c5828b91',
'ghcr.io/user/app:pr-15', 'ghcr.io/user/app:pr-15',
'ghcr.io/user/app:sha-a9c8c58' 'ghcr.io/user/app:sha-a9c8c5828b91'
], ],
[ [
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -2366,14 +2366,14 @@ describe('pr', () => {
] ]
} as Inputs, } as Inputs,
{ {
main: 'sha-a9c8c58', main: 'sha-a9c8c5828b91',
partial: ['pr-15'], partial: ['pr-15'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:sha-a9c8c58', 'org/app:sha-a9c8c5828b91',
'org/app:pr-15', 'org/app:pr-15',
'ghcr.io/user/app:sha-a9c8c58', 'ghcr.io/user/app:sha-a9c8c5828b91',
'ghcr.io/user/app:pr-15' 'ghcr.io/user/app:pr-15'
], ],
[ [
@ -2384,7 +2384,7 @@ describe('pr', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-a9c8c58" "org.opencontainers.image.version=sha-a9c8c5828b91"
], ],
undefined undefined
], ],
@ -2467,14 +2467,14 @@ describe('pr', () => {
] ]
} as Inputs, } as Inputs,
{ {
main: 'sha-2665741', main: 'sha-266574110acf',
partial: ['pr-15'], partial: ['pr-15'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:sha-2665741', 'org/app:sha-266574110acf',
'org/app:pr-15', 'org/app:pr-15',
'ghcr.io/user/app:sha-2665741', 'ghcr.io/user/app:sha-266574110acf',
'ghcr.io/user/app:pr-15' 'ghcr.io/user/app:pr-15'
], ],
[ [
@ -2485,7 +2485,7 @@ describe('pr', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-2665741" "org.opencontainers.image.version=sha-266574110acf"
], ],
undefined undefined
], ],
@ -2539,14 +2539,14 @@ describe('pr', () => {
{ {
main: 'pr-15', main: 'pr-15',
partial: [ partial: [
'sha-2665741', 'sha-266574110acf',
'sha-266574110acf203503badf966df2ea24b5d732d7' 'sha-266574110acf203503badf966df2ea24b5d732d7'
], ],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:pr-15', 'org/app:pr-15',
'org/app:sha-2665741', 'org/app:sha-266574110acf',
'org/app:sha-266574110acf203503badf966df2ea24b5d732d7' 'org/app:sha-266574110acf203503badf966df2ea24b5d732d7'
], ],
[ [
@ -2691,14 +2691,14 @@ describe('pr-head-sha', () => {
} as Inputs, } as Inputs,
{ {
main: 'pr-15', main: 'pr-15',
partial: ['sha-3370e22'], partial: ['sha-3370e228f220'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:pr-15', 'org/app:pr-15',
'org/app:sha-3370e22', 'org/app:sha-3370e228f220',
'ghcr.io/user/app:pr-15', 'ghcr.io/user/app:pr-15',
'ghcr.io/user/app:sha-3370e22' 'ghcr.io/user/app:sha-3370e228f220'
], ],
[ [
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -2722,14 +2722,14 @@ describe('pr-head-sha', () => {
] ]
} as Inputs, } as Inputs,
{ {
main: 'sha-3370e22', main: 'sha-3370e228f220',
partial: ['pr-15'], partial: ['pr-15'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:sha-3370e22', 'org/app:sha-3370e228f220',
'org/app:pr-15', 'org/app:pr-15',
'ghcr.io/user/app:sha-3370e22', 'ghcr.io/user/app:sha-3370e228f220',
'ghcr.io/user/app:pr-15' 'ghcr.io/user/app:pr-15'
], ],
[ [
@ -2740,7 +2740,7 @@ describe('pr-head-sha', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-3370e22" "org.opencontainers.image.version=sha-3370e228f220"
] ]
], ],
[ [
@ -2820,14 +2820,14 @@ describe('pr-head-sha', () => {
] ]
} as Inputs, } as Inputs,
{ {
main: 'sha-3370e22', main: 'sha-3370e228f220',
partial: ['pr-15'], partial: ['pr-15'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:sha-3370e22', 'org/app:sha-3370e228f220',
'org/app:pr-15', 'org/app:pr-15',
'ghcr.io/user/app:sha-3370e22', 'ghcr.io/user/app:sha-3370e228f220',
'ghcr.io/user/app:pr-15' 'ghcr.io/user/app:pr-15'
], ],
[ [
@ -2838,7 +2838,7 @@ describe('pr-head-sha', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-3370e22" "org.opencontainers.image.version=sha-3370e228f220"
] ]
], ],
[ [
@ -2890,14 +2890,14 @@ describe('pr-head-sha', () => {
{ {
main: 'pr-15', main: 'pr-15',
partial: [ partial: [
'sha-3370e22', 'sha-3370e228f220',
'sha-3370e228f2209994d57af4427fe64e71bb79ac96' 'sha-3370e228f2209994d57af4427fe64e71bb79ac96'
], ],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:pr-15', 'org/app:pr-15',
'org/app:sha-3370e22', 'org/app:sha-3370e228f220',
'org/app:sha-3370e228f2209994d57af4427fe64e71bb79ac96' 'org/app:sha-3370e228f2209994d57af4427fe64e71bb79ac96'
], ],
[ [
@ -3121,14 +3121,14 @@ describe('schedule', () => {
} as Inputs, } as Inputs,
{ {
main: 'nightly', main: 'nightly',
partial: ['sha-860c190'], partial: ['sha-860c1904a1ce'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:nightly', 'org/app:nightly',
'org/app:sha-860c190', 'org/app:sha-860c1904a1ce',
'ghcr.io/user/app:nightly', 'ghcr.io/user/app:nightly',
'ghcr.io/user/app:sha-860c190' 'ghcr.io/user/app:sha-860c1904a1ce'
], ],
[ [
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -3154,7 +3154,7 @@ describe('schedule', () => {
] ]
} as Inputs, } as Inputs,
{ {
main: 'sha-860c190', main: 'sha-860c1904a1ce',
partial: [ partial: [
'nightly', 'nightly',
'defbranch' 'defbranch'
@ -3162,10 +3162,10 @@ describe('schedule', () => {
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:sha-860c190', 'org/app:sha-860c1904a1ce',
'org/app:nightly', 'org/app:nightly',
'org/app:defbranch', 'org/app:defbranch',
'ghcr.io/user/app:sha-860c190', 'ghcr.io/user/app:sha-860c1904a1ce',
'ghcr.io/user/app:nightly', 'ghcr.io/user/app:nightly',
'ghcr.io/user/app:defbranch' 'ghcr.io/user/app:defbranch'
], ],
@ -3177,7 +3177,7 @@ describe('schedule', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-860c190" "org.opencontainers.image.version=sha-860c1904a1ce"
], ],
undefined undefined
], ],

View file

@ -307,7 +307,7 @@ export class Meta {
let val = this.context.sha; let val = this.context.sha;
if (tag.attrs['format'] === tcl.ShaFormat.Short) { if (tag.attrs['format'] === tcl.ShaFormat.Short) {
val = this.context.sha.substring(0, 7); val = this.context.sha.substring(0, 12);
} }
const vraw = this.setValue(val, tag); const vraw = this.setValue(val, tag);
@ -373,7 +373,7 @@ export class Meta {
return context.ref.replace(/^refs\/tags\//g, ''); return context.ref.replace(/^refs\/tags\//g, '');
}, },
sha: function () { sha: function () {
return context.sha.substring(0, 7); return context.sha.substring(0, 12);
}, },
base_ref: function () { base_ref: function () {
if (/^refs\/tags\//.test(context.ref) && context.payload?.base_ref != undefined) { if (/^refs\/tags\//.test(context.ref) && context.payload?.base_ref != undefined) {