DOCKER_METADATA_SHORT_SHA_LENGTH env var to customize short commit SHA length

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2024-10-31 10:27:42 +01:00
parent bb9c6dd583
commit c6cb763bee
3 changed files with 71 additions and 6 deletions

View File

@ -360,10 +360,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_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 `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`) |
## `context` input
@ -725,6 +726,24 @@ tags: |
Output Git short commit (or long if specified) as Docker tag like
`sha-860c1904a1ce`.
By default, the length of the short commit SHA is `12` characters. You can
increase this length for larger repositories by setting the
[`DOCKER_METADATA_SHORT_SHA_LENGTH` environment variable](#environment-variables):
```yaml
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
name/app
tags: |
type=sha
env:
DOCKER_METADATA_SHORT_SHA_LENGTH: 16
```
Extended attributes and default values:
```yaml