From 8099d257f6c654e287c2893f3c35c1a3dce6b5e6 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Tue, 19 Nov 2024 18:12:23 +0100 Subject: [PATCH] back to commit sha length of 7 Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- README.md | 16 ++--- __tests__/meta.test.ts | 132 ++++++++++++++++++++--------------------- src/meta.ts | 2 +- 3 files changed, 75 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index ac406154..6f25553f 100644 --- a/README.md +++ b/README.md @@ -361,11 +361,11 @@ So it can be used with our [Docker Build Push action](https://github.com/docker/ ### environment variables -| Name | Type | Description | -|--------------------------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------| -| `DOCKER_METADATA_PR_HEAD_SHA` | Bool | If `true`, set associated head SHA instead of commit SHA that triggered the workflow on pull request event | -| `DOCKER_METADATA_SHORT_SHA_LENGTH` | Number | Specifies the length of the [short commit SHA](#typesha) to ensure uniqueness. Default is `12`, but can be increased for larger repositories. | -| `DOCKER_METADATA_ANNOTATIONS_LEVELS` | String | Comma separated list of annotations levels to set for annotations output separated (default `manifest`) | +| Name | Type | Description | +|--------------------------------------|--------|----------------------------------------------------------------------------------------------------------------------------------------------| +| `DOCKER_METADATA_PR_HEAD_SHA` | Bool | If `true`, set associated head SHA instead of commit SHA that triggered the workflow on pull request event | +| `DOCKER_METADATA_SHORT_SHA_LENGTH` | Number | Specifies the length of the [short commit SHA](#typesha) to ensure uniqueness. Default is `7`, but can be increased for larger repositories. | +| `DOCKER_METADATA_ANNOTATIONS_LEVELS` | String | Comma separated list of annotations levels to set for annotations output separated (default `manifest`) | ## `context` input @@ -725,9 +725,9 @@ tags: | ``` Output Git short commit (or long if specified) as Docker tag like -`sha-860c1904a1ce`. +`sha-860c190`. -By default, the length of the short commit SHA is `12` characters. You can +By default, the length of the short commit SHA is `7` characters. You can increase this length for larger repositories by setting the [`DOCKER_METADATA_SHORT_SHA_LENGTH` environment variable](#environment-variables): @@ -742,7 +742,7 @@ increase this length for larger repositories by setting the tags: | type=sha env: - DOCKER_METADATA_SHORT_SHA_LENGTH: 16 + DOCKER_METADATA_SHORT_SHA_LENGTH: 12 ``` Extended attributes and default values: diff --git a/__tests__/meta.test.ts b/__tests__/meta.test.ts index e8f1bbd8..5da49035 100644 --- a/__tests__/meta.test.ts +++ b/__tests__/meta.test.ts @@ -319,14 +319,14 @@ describe('push', () => { } as Inputs, { main: 'dev', - partial: ['sha-860c1904a1ce'], + partial: ['sha-860c190'], latest: false } as Version, [ 'org/app:dev', - 'org/app:sha-860c1904a1ce', + 'org/app:sha-860c190', 'ghcr.io/user/app:dev', - 'ghcr.io/user/app:sha-860c1904a1ce' + 'ghcr.io/user/app:sha-860c190' ], [ "org.opencontainers.image.created=2020-01-10T00:30:00.000Z", @@ -352,14 +352,14 @@ describe('push', () => { } as Inputs, { main: 'edge', - partial: ['sha-266574110acf'], + partial: ['sha-2665741'], latest: false } as Version, [ 'org/app:edge', - 'org/app:sha-266574110acf', + 'org/app:sha-2665741', 'ghcr.io/user/app:edge', - 'ghcr.io/user/app:sha-266574110acf' + 'ghcr.io/user/app:sha-2665741' ], [ "org.opencontainers.image.created=2020-01-10T00:30:00.000Z", @@ -385,14 +385,14 @@ describe('push', () => { } as Inputs, { main: 'edge', - partial: ['sha-860c1904a1ce'], + partial: ['sha-860c190'], latest: false } as Version, [ 'org/app:edge', - 'org/app:sha-860c1904a1ce', + 'org/app:sha-860c190', 'ghcr.io/user/app:edge', - 'ghcr.io/user/app:sha-860c1904a1ce' + 'ghcr.io/user/app:sha-860c190' ], [ "org.opencontainers.image.created=2020-01-10T00:30:00.000Z", @@ -417,13 +417,13 @@ describe('push', () => { ], } as Inputs, { - main: 'sha-266574110acf', + main: 'sha-2665741', partial: [], latest: false } as Version, [ - 'org/app:sha-266574110acf', - 'ghcr.io/user/app:sha-266574110acf' + 'org/app:sha-2665741', + 'ghcr.io/user/app:sha-2665741' ], [ "org.opencontainers.image.created=2020-01-10T00:30:00.000Z", @@ -433,7 +433,7 @@ describe('push', () => { "org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.title=Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World", - "org.opencontainers.image.version=sha-266574110acf" + "org.opencontainers.image.version=sha-2665741" ], undefined ], @@ -448,13 +448,13 @@ describe('push', () => { ], } as Inputs, { - main: 'sha-983315b5e8d4', + main: 'sha-983315b', partial: [], latest: false } as Version, [ - 'org/app:sha-983315b5e8d4', - 'ghcr.io/user/app:sha-983315b5e8d4' + 'org/app:sha-983315b', + 'ghcr.io/user/app:sha-983315b' ], [ "org.opencontainers.image.created=2020-01-10T00:30:00.000Z", @@ -464,7 +464,7 @@ describe('push', () => { "org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.title=Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World", - "org.opencontainers.image.version=sha-983315b5e8d4" + "org.opencontainers.image.version=sha-983315b" ], undefined ], @@ -683,14 +683,14 @@ describe('push', () => { } as Inputs, { main: 'dev', - partial: ['sha-860c1904a1ce19322e91ac35af1ab07466440c37'], + partial: ['sha-860c19019322e91ac35af1ab07466440c37'], latest: false } as Version, [ 'org/app:dev', - 'org/app:sha-860c1904a1ce19322e91ac35af1ab07466440c37', + 'org/app:sha-860c19019322e91ac35af1ab07466440c37', 'ghcr.io/user/app:dev', - 'ghcr.io/user/app:sha-860c1904a1ce19322e91ac35af1ab07466440c37' + 'ghcr.io/user/app:sha-860c19019322e91ac35af1ab07466440c37' ], [ "org.opencontainers.image.created=2020-01-10T00:30:00.000Z", @@ -717,13 +717,13 @@ describe('push', () => { ], } as Inputs, { - main: 'sha-860c1904a1ce19322e91ac35af1ab07466440c37', + main: 'sha-860c19019322e91ac35af1ab07466440c37', partial: [], latest: false } as Version, [ - 'org/app:sha-860c1904a1ce19322e91ac35af1ab07466440c37', - 'ghcr.io/user/app:sha-860c1904a1ce19322e91ac35af1ab07466440c37' + 'org/app:sha-860c19019322e91ac35af1ab07466440c37', + 'ghcr.io/user/app:sha-860c19019322e91ac35af1ab07466440c37' ], [ "org.opencontainers.image.created=2020-01-10T00:30:00.000Z", @@ -733,7 +733,7 @@ describe('push', () => { "org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.title=Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World", - "org.opencontainers.image.version=sha-860c1904a1ce19322e91ac35af1ab07466440c37" + "org.opencontainers.image.version=sha-860c19019322e91ac35af1ab07466440c37" ], undefined ], @@ -752,12 +752,12 @@ describe('push', () => { ], } as Inputs, { - main: 'sha-860c1904a1ce19322e91ac35af1ab07466440c37', + main: 'sha-860c19019322e91ac35af1ab07466440c37', partial: [], latest: false } as Version, [ - 'org/app:sha-860c1904a1ce19322e91ac35af1ab07466440c37' + 'org/app:sha-860c19019322e91ac35af1ab07466440c37' ], [ "org.opencontainers.image.created=2020-01-10T00:30:00.000Z", @@ -767,7 +767,7 @@ describe('push', () => { "org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.title=Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World", - "org.opencontainers.image.version=sha-860c1904a1ce19322e91ac35af1ab07466440c37" + "org.opencontainers.image.version=sha-860c19019322e91ac35af1ab07466440c37" ], undefined ], @@ -1356,17 +1356,17 @@ describe('tag', () => { } as Inputs, { main: '1.0.0', - partial: ['1.0', 'sha-860c1904a1ce'], + partial: ['1.0', 'sha-860c190'], latest: true } as Version, [ 'org/app:1.0.0', 'org/app:1.0', - 'org/app:sha-860c1904a1ce', + 'org/app:sha-860c190', 'org/app:latest', 'ghcr.io/user/app:1.0.0', 'ghcr.io/user/app:1.0', - 'ghcr.io/user/app:sha-860c1904a1ce', + 'ghcr.io/user/app:sha-860c190', 'ghcr.io/user/app:latest' ], [ @@ -1396,17 +1396,17 @@ describe('tag', () => { } as Inputs, { main: '1.0.0', - partial: ['1.0', 'sha-860c1904a1ce'], + partial: ['1.0', 'sha-860c190'], latest: true } as Version, [ 'org/app:1.0.0', 'org/app:1.0', - 'org/app:sha-860c1904a1ce', + 'org/app:sha-860c190', 'org/app:latest', 'ghcr.io/user/app:1.0.0', 'ghcr.io/user/app:1.0', - 'ghcr.io/user/app:sha-860c1904a1ce', + 'ghcr.io/user/app:sha-860c190', 'ghcr.io/user/app:latest' ], [ @@ -1438,17 +1438,17 @@ describe('tag', () => { } as Inputs, { main: '1.0.0-dev', - partial: ['1.0', 'sha-860c1904a1ce-dev'], + partial: ['1.0', 'sha-860c190-dev'], latest: true } as Version, [ 'org/app:1.0.0-dev', 'org/app:1.0', - 'org/app:sha-860c1904a1ce-dev', + 'org/app:sha-860c190-dev', 'org/app:latest', 'ghcr.io/user/app:1.0.0-dev', 'ghcr.io/user/app:1.0', - 'ghcr.io/user/app:sha-860c1904a1ce-dev', + 'ghcr.io/user/app:sha-860c190-dev', 'ghcr.io/user/app:latest' ], [ @@ -2482,14 +2482,14 @@ describe('pr', () => { ] } as Inputs, { - main: 'sha-266574110acf', + main: 'sha-2665741', partial: ['pr-15'], latest: false } as Version, [ - 'org/app:sha-266574110acf', + 'org/app:sha-2665741', 'org/app:pr-15', - 'ghcr.io/user/app:sha-266574110acf', + 'ghcr.io/user/app:sha-2665741', 'ghcr.io/user/app:pr-15' ], [ @@ -2500,7 +2500,7 @@ describe('pr', () => { "org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.title=Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World", - "org.opencontainers.image.version=sha-266574110acf" + "org.opencontainers.image.version=sha-2665741" ], undefined ], @@ -2554,15 +2554,15 @@ describe('pr', () => { { main: 'pr-15', partial: [ - 'sha-266574110acf', - 'sha-266574110acf203503badf966df2ea24b5d732d7' + 'sha-2665741', + 'sha-2665741203503badf966df2ea24b5d732d7' ], latest: false } as Version, [ 'org/app:pr-15', - 'org/app:sha-266574110acf', - 'org/app:sha-266574110acf203503badf966df2ea24b5d732d7' + 'org/app:sha-2665741', + 'org/app:sha-2665741203503badf966df2ea24b5d732d7' ], [ "org.opencontainers.image.created=2020-01-10T00:30:00.000Z", @@ -2735,14 +2735,14 @@ describe('pr-head-sha', () => { } as Inputs, { main: 'pr-15', - partial: ['sha-3370e228f220'], + partial: ['sha-3370e22'], latest: false } as Version, [ 'org/app:pr-15', - 'org/app:sha-3370e228f220', + 'org/app:sha-3370e22', 'ghcr.io/user/app:pr-15', - 'ghcr.io/user/app:sha-3370e228f220' + 'ghcr.io/user/app:sha-3370e22' ], [ "org.opencontainers.image.created=2020-01-10T00:30:00.000Z", @@ -2766,14 +2766,14 @@ describe('pr-head-sha', () => { ] } as Inputs, { - main: 'sha-3370e228f220', + main: 'sha-3370e22', partial: ['pr-15'], latest: false } as Version, [ - 'org/app:sha-3370e228f220', + 'org/app:sha-3370e22', 'org/app:pr-15', - 'ghcr.io/user/app:sha-3370e228f220', + 'ghcr.io/user/app:sha-3370e22', 'ghcr.io/user/app:pr-15' ], [ @@ -2784,7 +2784,7 @@ describe('pr-head-sha', () => { "org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.title=Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World", - "org.opencontainers.image.version=sha-3370e228f220" + "org.opencontainers.image.version=sha-3370e22" ] ], [ @@ -2864,14 +2864,14 @@ describe('pr-head-sha', () => { ] } as Inputs, { - main: 'sha-3370e228f220', + main: 'sha-3370e22', partial: ['pr-15'], latest: false } as Version, [ - 'org/app:sha-3370e228f220', + 'org/app:sha-3370e22', 'org/app:pr-15', - 'ghcr.io/user/app:sha-3370e228f220', + 'ghcr.io/user/app:sha-3370e22', 'ghcr.io/user/app:pr-15' ], [ @@ -2882,7 +2882,7 @@ describe('pr-head-sha', () => { "org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.title=Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World", - "org.opencontainers.image.version=sha-3370e228f220" + "org.opencontainers.image.version=sha-3370e22" ] ], [ @@ -2934,15 +2934,15 @@ describe('pr-head-sha', () => { { main: 'pr-15', partial: [ - 'sha-3370e228f220', - 'sha-3370e228f2209994d57af4427fe64e71bb79ac96' + 'sha-3370e22', + 'sha-3370e229994d57af4427fe64e71bb79ac96' ], latest: false } as Version, [ 'org/app:pr-15', - 'org/app:sha-3370e228f220', - 'org/app:sha-3370e228f2209994d57af4427fe64e71bb79ac96' + 'org/app:sha-3370e22', + 'org/app:sha-3370e229994d57af4427fe64e71bb79ac96' ], [ "org.opencontainers.image.created=2020-01-10T00:30:00.000Z", @@ -3197,14 +3197,14 @@ describe('schedule', () => { } as Inputs, { main: 'nightly', - partial: ['sha-860c1904a1ce'], + partial: ['sha-860c190'], latest: false } as Version, [ 'org/app:nightly', - 'org/app:sha-860c1904a1ce', + 'org/app:sha-860c190', 'ghcr.io/user/app:nightly', - 'ghcr.io/user/app:sha-860c1904a1ce' + 'ghcr.io/user/app:sha-860c190' ], [ "org.opencontainers.image.created=2020-01-10T00:30:00.000Z", @@ -3230,7 +3230,7 @@ describe('schedule', () => { ] } as Inputs, { - main: 'sha-860c1904a1ce', + main: 'sha-860c190', partial: [ 'nightly', 'defbranch' @@ -3238,10 +3238,10 @@ describe('schedule', () => { latest: false } as Version, [ - 'org/app:sha-860c1904a1ce', + 'org/app:sha-860c190', 'org/app:nightly', 'org/app:defbranch', - 'ghcr.io/user/app:sha-860c1904a1ce', + 'ghcr.io/user/app:sha-860c190', 'ghcr.io/user/app:nightly', 'ghcr.io/user/app:defbranch' ], @@ -3253,7 +3253,7 @@ describe('schedule', () => { "org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.title=Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World", - "org.opencontainers.image.version=sha-860c1904a1ce" + "org.opencontainers.image.version=sha-860c190" ], undefined ], diff --git a/src/meta.ts b/src/meta.ts index 26faee03..06bf09f3 100644 --- a/src/meta.ts +++ b/src/meta.ts @@ -13,7 +13,7 @@ import * as icl from './image'; import * as tcl from './tag'; import * as fcl from './flavor'; -const defaultShortShaLength = 12; +const defaultShortShaLength = 7; export interface Version { main: string | undefined;