Skip to content

Commit 717909c

Browse files
committed
back to commit sha length of 7
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 8cb0002 commit 717909c

File tree

3 files changed

+61
-61
lines changed

3 files changed

+61
-61
lines changed

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,11 @@ So it can be used with our [Docker Build Push action](https://github.com/docker/
361361

362362
### environment variables
363363

364-
| Name | Type | Description |
365-
|--------------------------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------|
366-
| `DOCKER_METADATA_PR_HEAD_SHA` | Bool | If `true`, set associated head SHA instead of commit SHA that triggered the workflow on pull request event |
367-
| `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. |
368-
| `DOCKER_METADATA_ANNOTATIONS_LEVELS` | String | Comma separated list of annotations levels to set for annotations output separated (default `manifest`) |
364+
| Name | Type | Description |
365+
|--------------------------------------|--------|----------------------------------------------------------------------------------------------------------------------------------------------|
366+
| `DOCKER_METADATA_PR_HEAD_SHA` | Bool | If `true`, set associated head SHA instead of commit SHA that triggered the workflow on pull request event |
367+
| `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. |
368+
| `DOCKER_METADATA_ANNOTATIONS_LEVELS` | String | Comma separated list of annotations levels to set for annotations output separated (default `manifest`) |
369369

370370
## `context` input
371371

@@ -725,9 +725,9 @@ tags: |
725725
```
726726

727727
Output Git short commit (or long if specified) as Docker tag like
728-
`sha-860c1904a1ce`.
728+
`sha-860c190`.
729729

730-
By default, the length of the short commit SHA is `12` characters. You can
730+
By default, the length of the short commit SHA is `7` characters. You can
731731
increase this length for larger repositories by setting the
732732
[`DOCKER_METADATA_SHORT_SHA_LENGTH` environment variable](#environment-variables):
733733

@@ -742,7 +742,7 @@ increase this length for larger repositories by setting the
742742
tags: |
743743
type=sha
744744
env:
745-
DOCKER_METADATA_SHORT_SHA_LENGTH: 16
745+
DOCKER_METADATA_SHORT_SHA_LENGTH: 12
746746
```
747747

748748
Extended attributes and default values:

__tests__/meta.test.ts

+52-52
Original file line numberDiff line numberDiff line change
@@ -319,14 +319,14 @@ describe('push', () => {
319319
} as Inputs,
320320
{
321321
main: 'dev',
322-
partial: ['sha-860c1904a1ce'],
322+
partial: ['sha-860c190'],
323323
latest: false
324324
} as Version,
325325
[
326326
'org/app:dev',
327-
'org/app:sha-860c1904a1ce',
327+
'org/app:sha-860c190',
328328
'ghcr.io/user/app:dev',
329-
'ghcr.io/user/app:sha-860c1904a1ce'
329+
'ghcr.io/user/app:sha-860c190'
330330
],
331331
[
332332
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@@ -352,14 +352,14 @@ describe('push', () => {
352352
} as Inputs,
353353
{
354354
main: 'edge',
355-
partial: ['sha-266574110acf'],
355+
partial: ['sha-2665741'],
356356
latest: false
357357
} as Version,
358358
[
359359
'org/app:edge',
360-
'org/app:sha-266574110acf',
360+
'org/app:sha-2665741',
361361
'ghcr.io/user/app:edge',
362-
'ghcr.io/user/app:sha-266574110acf'
362+
'ghcr.io/user/app:sha-2665741'
363363
],
364364
[
365365
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@@ -385,14 +385,14 @@ describe('push', () => {
385385
} as Inputs,
386386
{
387387
main: 'edge',
388-
partial: ['sha-860c1904a1ce'],
388+
partial: ['sha-860c190'],
389389
latest: false
390390
} as Version,
391391
[
392392
'org/app:edge',
393-
'org/app:sha-860c1904a1ce',
393+
'org/app:sha-860c190',
394394
'ghcr.io/user/app:edge',
395-
'ghcr.io/user/app:sha-860c1904a1ce'
395+
'ghcr.io/user/app:sha-860c190'
396396
],
397397
[
398398
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@@ -417,13 +417,13 @@ describe('push', () => {
417417
],
418418
} as Inputs,
419419
{
420-
main: 'sha-266574110acf',
420+
main: 'sha-2665741',
421421
partial: [],
422422
latest: false
423423
} as Version,
424424
[
425-
'org/app:sha-266574110acf',
426-
'ghcr.io/user/app:sha-266574110acf'
425+
'org/app:sha-2665741',
426+
'ghcr.io/user/app:sha-2665741'
427427
],
428428
[
429429
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@@ -433,7 +433,7 @@ describe('push', () => {
433433
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
434434
"org.opencontainers.image.title=Hello-World",
435435
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
436-
"org.opencontainers.image.version=sha-266574110acf"
436+
"org.opencontainers.image.version=sha-2665741"
437437
],
438438
undefined
439439
],
@@ -448,13 +448,13 @@ describe('push', () => {
448448
],
449449
} as Inputs,
450450
{
451-
main: 'sha-983315b5e8d4',
451+
main: 'sha-983315b',
452452
partial: [],
453453
latest: false
454454
} as Version,
455455
[
456-
'org/app:sha-983315b5e8d4',
457-
'ghcr.io/user/app:sha-983315b5e8d4'
456+
'org/app:sha-983315b',
457+
'ghcr.io/user/app:sha-983315b'
458458
],
459459
[
460460
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@@ -464,7 +464,7 @@ describe('push', () => {
464464
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
465465
"org.opencontainers.image.title=Hello-World",
466466
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
467-
"org.opencontainers.image.version=sha-983315b5e8d4"
467+
"org.opencontainers.image.version=sha-983315b"
468468
],
469469
undefined
470470
],
@@ -1356,17 +1356,17 @@ describe('tag', () => {
13561356
} as Inputs,
13571357
{
13581358
main: '1.0.0',
1359-
partial: ['1.0', 'sha-860c1904a1ce'],
1359+
partial: ['1.0', 'sha-860c190'],
13601360
latest: true
13611361
} as Version,
13621362
[
13631363
'org/app:1.0.0',
13641364
'org/app:1.0',
1365-
'org/app:sha-860c1904a1ce',
1365+
'org/app:sha-860c190',
13661366
'org/app:latest',
13671367
'ghcr.io/user/app:1.0.0',
13681368
'ghcr.io/user/app:1.0',
1369-
'ghcr.io/user/app:sha-860c1904a1ce',
1369+
'ghcr.io/user/app:sha-860c190',
13701370
'ghcr.io/user/app:latest'
13711371
],
13721372
[
@@ -1396,17 +1396,17 @@ describe('tag', () => {
13961396
} as Inputs,
13971397
{
13981398
main: '1.0.0',
1399-
partial: ['1.0', 'sha-860c1904a1ce'],
1399+
partial: ['1.0', 'sha-860c190'],
14001400
latest: true
14011401
} as Version,
14021402
[
14031403
'org/app:1.0.0',
14041404
'org/app:1.0',
1405-
'org/app:sha-860c1904a1ce',
1405+
'org/app:sha-860c190',
14061406
'org/app:latest',
14071407
'ghcr.io/user/app:1.0.0',
14081408
'ghcr.io/user/app:1.0',
1409-
'ghcr.io/user/app:sha-860c1904a1ce',
1409+
'ghcr.io/user/app:sha-860c190',
14101410
'ghcr.io/user/app:latest'
14111411
],
14121412
[
@@ -1438,17 +1438,17 @@ describe('tag', () => {
14381438
} as Inputs,
14391439
{
14401440
main: '1.0.0-dev',
1441-
partial: ['1.0', 'sha-860c1904a1ce-dev'],
1441+
partial: ['1.0', 'sha-860c190-dev'],
14421442
latest: true
14431443
} as Version,
14441444
[
14451445
'org/app:1.0.0-dev',
14461446
'org/app:1.0',
1447-
'org/app:sha-860c1904a1ce-dev',
1447+
'org/app:sha-860c190-dev',
14481448
'org/app:latest',
14491449
'ghcr.io/user/app:1.0.0-dev',
14501450
'ghcr.io/user/app:1.0',
1451-
'ghcr.io/user/app:sha-860c1904a1ce-dev',
1451+
'ghcr.io/user/app:sha-860c190-dev',
14521452
'ghcr.io/user/app:latest'
14531453
],
14541454
[
@@ -2482,14 +2482,14 @@ describe('pr', () => {
24822482
]
24832483
} as Inputs,
24842484
{
2485-
main: 'sha-266574110acf',
2485+
main: 'sha-2665741',
24862486
partial: ['pr-15'],
24872487
latest: false
24882488
} as Version,
24892489
[
2490-
'org/app:sha-266574110acf',
2490+
'org/app:sha-2665741',
24912491
'org/app:pr-15',
2492-
'ghcr.io/user/app:sha-266574110acf',
2492+
'ghcr.io/user/app:sha-2665741',
24932493
'ghcr.io/user/app:pr-15'
24942494
],
24952495
[
@@ -2500,7 +2500,7 @@ describe('pr', () => {
25002500
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
25012501
"org.opencontainers.image.title=Hello-World",
25022502
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
2503-
"org.opencontainers.image.version=sha-266574110acf"
2503+
"org.opencontainers.image.version=sha-2665741"
25042504
],
25052505
undefined
25062506
],
@@ -2554,14 +2554,14 @@ describe('pr', () => {
25542554
{
25552555
main: 'pr-15',
25562556
partial: [
2557-
'sha-266574110acf',
2557+
'sha-2665741',
25582558
'sha-266574110acf203503badf966df2ea24b5d732d7'
25592559
],
25602560
latest: false
25612561
} as Version,
25622562
[
25632563
'org/app:pr-15',
2564-
'org/app:sha-266574110acf',
2564+
'org/app:sha-2665741',
25652565
'org/app:sha-266574110acf203503badf966df2ea24b5d732d7'
25662566
],
25672567
[
@@ -2735,14 +2735,14 @@ describe('pr-head-sha', () => {
27352735
} as Inputs,
27362736
{
27372737
main: 'pr-15',
2738-
partial: ['sha-3370e228f220'],
2738+
partial: ['sha-3370e22'],
27392739
latest: false
27402740
} as Version,
27412741
[
27422742
'org/app:pr-15',
2743-
'org/app:sha-3370e228f220',
2743+
'org/app:sha-3370e22',
27442744
'ghcr.io/user/app:pr-15',
2745-
'ghcr.io/user/app:sha-3370e228f220'
2745+
'ghcr.io/user/app:sha-3370e22'
27462746
],
27472747
[
27482748
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@@ -2766,14 +2766,14 @@ describe('pr-head-sha', () => {
27662766
]
27672767
} as Inputs,
27682768
{
2769-
main: 'sha-3370e228f220',
2769+
main: 'sha-3370e22',
27702770
partial: ['pr-15'],
27712771
latest: false
27722772
} as Version,
27732773
[
2774-
'org/app:sha-3370e228f220',
2774+
'org/app:sha-3370e22',
27752775
'org/app:pr-15',
2776-
'ghcr.io/user/app:sha-3370e228f220',
2776+
'ghcr.io/user/app:sha-3370e22',
27772777
'ghcr.io/user/app:pr-15'
27782778
],
27792779
[
@@ -2784,7 +2784,7 @@ describe('pr-head-sha', () => {
27842784
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
27852785
"org.opencontainers.image.title=Hello-World",
27862786
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
2787-
"org.opencontainers.image.version=sha-3370e228f220"
2787+
"org.opencontainers.image.version=sha-3370e22"
27882788
]
27892789
],
27902790
[
@@ -2864,14 +2864,14 @@ describe('pr-head-sha', () => {
28642864
]
28652865
} as Inputs,
28662866
{
2867-
main: 'sha-3370e228f220',
2867+
main: 'sha-3370e22',
28682868
partial: ['pr-15'],
28692869
latest: false
28702870
} as Version,
28712871
[
2872-
'org/app:sha-3370e228f220',
2872+
'org/app:sha-3370e22',
28732873
'org/app:pr-15',
2874-
'ghcr.io/user/app:sha-3370e228f220',
2874+
'ghcr.io/user/app:sha-3370e22',
28752875
'ghcr.io/user/app:pr-15'
28762876
],
28772877
[
@@ -2882,7 +2882,7 @@ describe('pr-head-sha', () => {
28822882
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
28832883
"org.opencontainers.image.title=Hello-World",
28842884
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
2885-
"org.opencontainers.image.version=sha-3370e228f220"
2885+
"org.opencontainers.image.version=sha-3370e22"
28862886
]
28872887
],
28882888
[
@@ -2934,14 +2934,14 @@ describe('pr-head-sha', () => {
29342934
{
29352935
main: 'pr-15',
29362936
partial: [
2937-
'sha-3370e228f220',
2937+
'sha-3370e22',
29382938
'sha-3370e228f2209994d57af4427fe64e71bb79ac96'
29392939
],
29402940
latest: false
29412941
} as Version,
29422942
[
29432943
'org/app:pr-15',
2944-
'org/app:sha-3370e228f220',
2944+
'org/app:sha-3370e22',
29452945
'org/app:sha-3370e228f2209994d57af4427fe64e71bb79ac96'
29462946
],
29472947
[
@@ -3197,14 +3197,14 @@ describe('schedule', () => {
31973197
} as Inputs,
31983198
{
31993199
main: 'nightly',
3200-
partial: ['sha-860c1904a1ce'],
3200+
partial: ['sha-860c190'],
32013201
latest: false
32023202
} as Version,
32033203
[
32043204
'org/app:nightly',
3205-
'org/app:sha-860c1904a1ce',
3205+
'org/app:sha-860c190',
32063206
'ghcr.io/user/app:nightly',
3207-
'ghcr.io/user/app:sha-860c1904a1ce'
3207+
'ghcr.io/user/app:sha-860c190'
32083208
],
32093209
[
32103210
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@@ -3230,18 +3230,18 @@ describe('schedule', () => {
32303230
]
32313231
} as Inputs,
32323232
{
3233-
main: 'sha-860c1904a1ce',
3233+
main: 'sha-860c190',
32343234
partial: [
32353235
'nightly',
32363236
'defbranch'
32373237
],
32383238
latest: false
32393239
} as Version,
32403240
[
3241-
'org/app:sha-860c1904a1ce',
3241+
'org/app:sha-860c190',
32423242
'org/app:nightly',
32433243
'org/app:defbranch',
3244-
'ghcr.io/user/app:sha-860c1904a1ce',
3244+
'ghcr.io/user/app:sha-860c190',
32453245
'ghcr.io/user/app:nightly',
32463246
'ghcr.io/user/app:defbranch'
32473247
],
@@ -3253,7 +3253,7 @@ describe('schedule', () => {
32533253
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
32543254
"org.opencontainers.image.title=Hello-World",
32553255
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
3256-
"org.opencontainers.image.version=sha-860c1904a1ce"
3256+
"org.opencontainers.image.version=sha-860c190"
32573257
],
32583258
undefined
32593259
],

src/meta.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import * as icl from './image';
1313
import * as tcl from './tag';
1414
import * as fcl from './flavor';
1515

16-
const defaultShortShaLength = 12;
16+
const defaultShortShaLength = 7;
1717

1818
export interface Version {
1919
main: string | undefined;

0 commit comments

Comments
 (0)