Skip to content

Commit

Permalink
back to commit sha length of 7
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Nov 19, 2024
1 parent 8cb0002 commit 717909c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 61 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):

Expand All @@ -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:
Expand Down
104 changes: 52 additions & 52 deletions __tests__/meta.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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
],
Expand All @@ -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",
Expand All @@ -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
],
Expand Down Expand Up @@ -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'
],
[
Expand Down Expand Up @@ -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'
],
[
Expand Down Expand Up @@ -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'
],
[
Expand Down Expand Up @@ -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'
],
[
Expand All @@ -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
],
Expand Down Expand Up @@ -2554,14 +2554,14 @@ describe('pr', () => {
{
main: 'pr-15',
partial: [
'sha-266574110acf',
'sha-2665741',
'sha-266574110acf203503badf966df2ea24b5d732d7'
],
latest: false
} as Version,
[
'org/app:pr-15',
'org/app:sha-266574110acf',
'org/app:sha-2665741',
'org/app:sha-266574110acf203503badf966df2ea24b5d732d7'
],
[
Expand Down Expand Up @@ -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",
Expand All @@ -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'
],
[
Expand All @@ -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"
]
],
[
Expand Down Expand Up @@ -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'
],
[
Expand All @@ -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"
]
],
[
Expand Down Expand Up @@ -2934,14 +2934,14 @@ describe('pr-head-sha', () => {
{
main: 'pr-15',
partial: [
'sha-3370e228f220',
'sha-3370e22',
'sha-3370e228f2209994d57af4427fe64e71bb79ac96'
],
latest: false
} as Version,
[
'org/app:pr-15',
'org/app:sha-3370e228f220',
'org/app:sha-3370e22',
'org/app:sha-3370e228f2209994d57af4427fe64e71bb79ac96'
],
[
Expand Down Expand Up @@ -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",
Expand All @@ -3230,18 +3230,18 @@ describe('schedule', () => {
]
} as Inputs,
{
main: 'sha-860c1904a1ce',
main: 'sha-860c190',
partial: [
'nightly',
'defbranch'
],
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'
],
Expand All @@ -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
],
Expand Down
2 changes: 1 addition & 1 deletion src/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 717909c

Please sign in to comment.