Merge pull request #467 from crazy-max/increase-short-sha-size
increase short commit hash length to 12 for uniqueness
This commit is contained in:
6 files changed
+138
-72
No files matched your search
@@ -549,3 +549,33 @@ jobs:
|
||||
cwd://${{ steps.docker_meta.outputs.bake-file-labels }}
|
||||
targets: |
|
||||
release
|
||||
|
||||
sha-short:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
short-length:
|
||||
- ''
|
||||
- 16
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
version: ${{ env.BUILDX_VERSION }}
|
||||
driver: docker
|
||||
-
|
||||
name: Docker meta
|
||||
uses: ./
|
||||
with:
|
||||
images: |
|
||||
${{ env.DOCKER_IMAGE }}
|
||||
ghcr.io/name/app
|
||||
tags: |
|
||||
type=sha
|
||||
env:
|
||||
DOCKER_METADATA_SHORT_SHA_LENGTH: ${{ matrix.short-length }}
|
||||
@@ -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
|
||||
|
||||
@@ -722,7 +723,26 @@ tags: |
|
||||
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`.
|
||||
|
||||
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:
|
||||
|
||||
|
||||
+63
-63
@@ -310,14 +310,14 @@ describe('push', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'dev',
|
||||
partial: ['sha-860c190'],
|
||||
partial: ['sha-860c1904a1ce'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:dev',
|
||||
'org/app:sha-860c190',
|
||||
'org/app:sha-860c1904a1ce',
|
||||
'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",
|
||||
@@ -343,14 +343,14 @@ describe('push', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'edge',
|
||||
partial: ['sha-2665741'],
|
||||
partial: ['sha-266574110acf'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:edge',
|
||||
'org/app:sha-2665741',
|
||||
'org/app:sha-266574110acf',
|
||||
'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",
|
||||
@@ -376,14 +376,14 @@ describe('push', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'edge',
|
||||
partial: ['sha-860c190'],
|
||||
partial: ['sha-860c1904a1ce'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:edge',
|
||||
'org/app:sha-860c190',
|
||||
'org/app:sha-860c1904a1ce',
|
||||
'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",
|
||||
@@ -408,13 +408,13 @@ describe('push', () => {
|
||||
],
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'sha-2665741',
|
||||
main: 'sha-266574110acf',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:sha-2665741',
|
||||
'ghcr.io/user/app:sha-2665741'
|
||||
'org/app:sha-266574110acf',
|
||||
'ghcr.io/user/app:sha-266574110acf'
|
||||
],
|
||||
[
|
||||
"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.title=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
|
||||
],
|
||||
@@ -439,13 +439,13 @@ describe('push', () => {
|
||||
],
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'sha-983315b',
|
||||
main: 'sha-983315b5e8d4',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:sha-983315b',
|
||||
'ghcr.io/user/app:sha-983315b'
|
||||
'org/app:sha-983315b5e8d4',
|
||||
'ghcr.io/user/app:sha-983315b5e8d4'
|
||||
],
|
||||
[
|
||||
"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.title=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
|
||||
],
|
||||
@@ -1341,17 +1341,17 @@ describe('tag', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
main: '1.0.0',
|
||||
partial: ['1.0', 'sha-860c190'],
|
||||
partial: ['1.0', 'sha-860c1904a1ce'],
|
||||
latest: true
|
||||
} as Version,
|
||||
[
|
||||
'org/app:1.0.0',
|
||||
'org/app:1.0',
|
||||
'org/app:sha-860c190',
|
||||
'org/app:sha-860c1904a1ce',
|
||||
'org/app:latest',
|
||||
'ghcr.io/user/app:1.0.0',
|
||||
'ghcr.io/user/app:1.0',
|
||||
'ghcr.io/user/app:sha-860c190',
|
||||
'ghcr.io/user/app:sha-860c1904a1ce',
|
||||
'ghcr.io/user/app:latest'
|
||||
],
|
||||
[
|
||||
@@ -1381,17 +1381,17 @@ describe('tag', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
main: '1.0.0',
|
||||
partial: ['1.0', 'sha-860c190'],
|
||||
partial: ['1.0', 'sha-860c1904a1ce'],
|
||||
latest: true
|
||||
} as Version,
|
||||
[
|
||||
'org/app:1.0.0',
|
||||
'org/app:1.0',
|
||||
'org/app:sha-860c190',
|
||||
'org/app:sha-860c1904a1ce',
|
||||
'org/app:latest',
|
||||
'ghcr.io/user/app:1.0.0',
|
||||
'ghcr.io/user/app:1.0',
|
||||
'ghcr.io/user/app:sha-860c190',
|
||||
'ghcr.io/user/app:sha-860c1904a1ce',
|
||||
'ghcr.io/user/app:latest'
|
||||
],
|
||||
[
|
||||
@@ -1423,17 +1423,17 @@ describe('tag', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
main: '1.0.0-dev',
|
||||
partial: ['1.0', 'sha-860c190-dev'],
|
||||
partial: ['1.0', 'sha-860c1904a1ce-dev'],
|
||||
latest: true
|
||||
} as Version,
|
||||
[
|
||||
'org/app:1.0.0-dev',
|
||||
'org/app:1.0',
|
||||
'org/app:sha-860c190-dev',
|
||||
'org/app:sha-860c1904a1ce-dev',
|
||||
'org/app:latest',
|
||||
'ghcr.io/user/app:1.0.0-dev',
|
||||
'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'
|
||||
],
|
||||
[
|
||||
@@ -1460,16 +1460,16 @@ describe('tag', () => {
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'v1.1.1-860c190-foo',
|
||||
main: 'v1.1.1-860c1904a1ce-foo',
|
||||
partial: [
|
||||
'master-foo'
|
||||
],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:v1.1.1-860c190-foo',
|
||||
'org/app:v1.1.1-860c1904a1ce-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'
|
||||
],
|
||||
[
|
||||
@@ -1480,7 +1480,7 @@ describe('tag', () => {
|
||||
"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=v1.1.1-860c190-foo"
|
||||
"org.opencontainers.image.version=v1.1.1-860c1904a1ce-foo"
|
||||
],
|
||||
undefined
|
||||
],
|
||||
@@ -2334,14 +2334,14 @@ describe('pr', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'pr-15',
|
||||
partial: ['sha-a9c8c58'],
|
||||
partial: ['sha-a9c8c5828b91'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:pr-15',
|
||||
'org/app:sha-a9c8c58',
|
||||
'org/app:sha-a9c8c5828b91',
|
||||
'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",
|
||||
@@ -2366,14 +2366,14 @@ describe('pr', () => {
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'sha-a9c8c58',
|
||||
main: 'sha-a9c8c5828b91',
|
||||
partial: ['pr-15'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:sha-a9c8c58',
|
||||
'org/app:sha-a9c8c5828b91',
|
||||
'org/app:pr-15',
|
||||
'ghcr.io/user/app:sha-a9c8c58',
|
||||
'ghcr.io/user/app:sha-a9c8c5828b91',
|
||||
'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.title=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
|
||||
],
|
||||
@@ -2467,14 +2467,14 @@ describe('pr', () => {
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'sha-2665741',
|
||||
main: 'sha-266574110acf',
|
||||
partial: ['pr-15'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:sha-2665741',
|
||||
'org/app:sha-266574110acf',
|
||||
'org/app:pr-15',
|
||||
'ghcr.io/user/app:sha-2665741',
|
||||
'ghcr.io/user/app:sha-266574110acf',
|
||||
'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.title=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
|
||||
],
|
||||
@@ -2539,14 +2539,14 @@ describe('pr', () => {
|
||||
{
|
||||
main: 'pr-15',
|
||||
partial: [
|
||||
'sha-2665741',
|
||||
'sha-266574110acf',
|
||||
'sha-266574110acf203503badf966df2ea24b5d732d7'
|
||||
],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:pr-15',
|
||||
'org/app:sha-2665741',
|
||||
'org/app:sha-266574110acf',
|
||||
'org/app:sha-266574110acf203503badf966df2ea24b5d732d7'
|
||||
],
|
||||
[
|
||||
@@ -2691,14 +2691,14 @@ describe('pr-head-sha', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'pr-15',
|
||||
partial: ['sha-3370e22'],
|
||||
partial: ['sha-3370e228f220'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:pr-15',
|
||||
'org/app:sha-3370e22',
|
||||
'org/app:sha-3370e228f220',
|
||||
'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",
|
||||
@@ -2722,14 +2722,14 @@ describe('pr-head-sha', () => {
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'sha-3370e22',
|
||||
main: 'sha-3370e228f220',
|
||||
partial: ['pr-15'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:sha-3370e22',
|
||||
'org/app:sha-3370e228f220',
|
||||
'org/app:pr-15',
|
||||
'ghcr.io/user/app:sha-3370e22',
|
||||
'ghcr.io/user/app:sha-3370e228f220',
|
||||
'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.title=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,
|
||||
{
|
||||
main: 'sha-3370e22',
|
||||
main: 'sha-3370e228f220',
|
||||
partial: ['pr-15'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:sha-3370e22',
|
||||
'org/app:sha-3370e228f220',
|
||||
'org/app:pr-15',
|
||||
'ghcr.io/user/app:sha-3370e22',
|
||||
'ghcr.io/user/app:sha-3370e228f220',
|
||||
'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.title=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',
|
||||
partial: [
|
||||
'sha-3370e22',
|
||||
'sha-3370e228f220',
|
||||
'sha-3370e228f2209994d57af4427fe64e71bb79ac96'
|
||||
],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:pr-15',
|
||||
'org/app:sha-3370e22',
|
||||
'org/app:sha-3370e228f220',
|
||||
'org/app:sha-3370e228f2209994d57af4427fe64e71bb79ac96'
|
||||
],
|
||||
[
|
||||
@@ -3121,14 +3121,14 @@ describe('schedule', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'nightly',
|
||||
partial: ['sha-860c190'],
|
||||
partial: ['sha-860c1904a1ce'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:nightly',
|
||||
'org/app:sha-860c190',
|
||||
'org/app:sha-860c1904a1ce',
|
||||
'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",
|
||||
@@ -3154,7 +3154,7 @@ describe('schedule', () => {
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'sha-860c190',
|
||||
main: 'sha-860c1904a1ce',
|
||||
partial: [
|
||||
'nightly',
|
||||
'defbranch'
|
||||
@@ -3162,10 +3162,10 @@ describe('schedule', () => {
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:sha-860c190',
|
||||
'org/app:sha-860c1904a1ce',
|
||||
'org/app:nightly',
|
||||
'org/app:defbranch',
|
||||
'ghcr.io/user/app:sha-860c190',
|
||||
'ghcr.io/user/app:sha-860c1904a1ce',
|
||||
'ghcr.io/user/app:nightly',
|
||||
'ghcr.io/user/app:defbranch'
|
||||
],
|
||||
@@ -3177,7 +3177,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-860c190"
|
||||
"org.opencontainers.image.version=sha-860c1904a1ce"
|
||||
],
|
||||
undefined
|
||||
],
|
||||
|
||||
+1
-1
@@ -157,5 +157,5 @@ const c=a(57147);const p=a(22037);const l=a(71017);const d=a(6113);const u={fs:c
|
||||
* @license [MIT]{@link https://github.com/archiverjs/node-zip-stream/blob/master/LICENSE}
|
||||
* @copyright (c) 2014 Chris Talkington, contributors.
|
||||
*/
|
||||
var c=a(73837).inherits;var p=a(25445).ZipArchiveOutputStream;var l=a(25445).ZipArchiveEntry;var d=a(82072);var u=r.exports=function(r){if(!(this instanceof u)){return new u(r)}r=this.options=r||{};r.zlib=r.zlib||{};p.call(this,r);if(typeof r.level==="number"&&r.level>=0){r.zlib.level=r.level;delete r.level}if(!r.forceZip64&&typeof r.zlib.level==="number"&&r.zlib.level===0){r.store=true}r.namePrependSlash=r.namePrependSlash||false;if(r.comment&&r.comment.length>0){this.setComment(r.comment)}};c(u,p);u.prototype._normalizeFileData=function(r){r=d.defaults(r,{type:"file",name:null,namePrependSlash:this.options.namePrependSlash,linkname:null,date:null,mode:null,store:this.options.store,comment:""});var i=r.type==="directory";var a=r.type==="symlink";if(r.name){r.name=d.sanitizePath(r.name);if(!a&&r.name.slice(-1)==="/"){i=true;r.type="directory"}else if(i){r.name+="/"}}if(i||a){r.store=true}r.date=d.dateify(r.date);return r};u.prototype.entry=function(r,i,a){if(typeof a!=="function"){a=this._emitErrorCallback.bind(this)}i=this._normalizeFileData(i);if(i.type!=="file"&&i.type!=="directory"&&i.type!=="symlink"){a(new Error(i.type+" entries not currently supported"));return}if(typeof i.name!=="string"||i.name.length===0){a(new Error("entry name must be a non-empty string value"));return}if(i.type==="symlink"&&typeof i.linkname!=="string"){a(new Error("entry linkname must be a non-empty string value when type equals symlink"));return}var c=new l(i.name);c.setTime(i.date,this.options.forceLocalTime);if(i.namePrependSlash){c.setName(i.name,true)}if(i.store){c.setMethod(0)}if(i.comment.length>0){c.setComment(i.comment)}if(i.type==="symlink"&&typeof i.mode!=="number"){i.mode=40960}if(typeof i.mode==="number"){if(i.type==="symlink"){i.mode|=40960}c.setUnixMode(i.mode)}if(i.type==="symlink"&&typeof i.linkname==="string"){r=Buffer.from(i.linkname)}return p.prototype.entry.call(this,c,r,a)};u.prototype.finalize=function(){this.finish()}},98954:function(r,i,a){"use strict";var c=this&&this.__createBinding||(Object.create?function(r,i,a,c){if(c===undefined)c=a;var p=Object.getOwnPropertyDescriptor(i,a);if(!p||("get"in p?!i.__esModule:p.writable||p.configurable)){p={enumerable:true,get:function(){return i[a]}}}Object.defineProperty(r,c,p)}:function(r,i,a,c){if(c===undefined)c=a;r[c]=i[a]});var p=this&&this.__setModuleDefault||(Object.create?function(r,i){Object.defineProperty(r,"default",{enumerable:true,value:i})}:function(r,i){r["default"]=i});var l=this&&this.__importStar||function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a in r)if(a!=="default"&&Object.prototype.hasOwnProperty.call(r,a))c(i,r,a);p(i,r);return i};var d=this&&this.__awaiter||function(r,i,a,c){function adopt(r){return r instanceof a?r:new a((function(i){i(r)}))}return new(a||(a=Promise))((function(a,p){function fulfilled(r){try{step(c.next(r))}catch(r){p(r)}}function rejected(r){try{step(c["throw"](r))}catch(r){p(r)}}function step(r){r.done?a(r.value):adopt(r.value).then(fulfilled,rejected)}step((c=c.apply(r,i||[])).next())}))};Object.defineProperty(i,"__esModule",{value:true});i.getContext=i.ContextSource=i.getInputs=void 0;const u=l(a(42186));const A=a(28662);const b=a(26074);const h=a(6276);function getInputs(){return{context:u.getInput("context")||g.workflow,images:A.Util.getInputList("images",{ignoreComma:true,comment:"#"}),tags:A.Util.getInputList("tags",{ignoreComma:true,comment:"#"}),flavor:A.Util.getInputList("flavor",{ignoreComma:true,comment:"#"}),labels:A.Util.getInputList("labels",{ignoreComma:true,comment:"#"}),annotations:A.Util.getInputList("annotations",{ignoreComma:true,comment:"#"}),sepTags:u.getInput("sep-tags",{trimWhitespace:false})||`\n`,sepLabels:u.getInput("sep-labels",{trimWhitespace:false})||`\n`,sepAnnotations:u.getInput("sep-annotations",{trimWhitespace:false})||`\n`,bakeTarget:u.getInput("bake-target")||`docker-metadata-action`,githubToken:u.getInput("github-token")}}i.getInputs=getInputs;var g;(function(r){r["workflow"]="workflow";r["git"]="git"})(g||(i.ContextSource=g={}));function getContext(r){return d(this,void 0,void 0,(function*(){switch(r){case g.workflow:return getContextFromWorkflow();case g.git:return yield getContextFromGit();default:throw new Error(`Invalid context source: ${r}`)}}))}i.getContext=getContext;function getContextFromWorkflow(){var r,i,a;const c=h.GitHub.context;if(/pull_request_target/.test(c.eventName)){c.ref=`refs/pull/${c.payload.number}/merge`}if(/true/i.test(process.env.DOCKER_METADATA_PR_HEAD_SHA||"")){if((/pull_request/.test(c.eventName)||/pull_request_target/.test(c.eventName))&&((a=(i=(r=c.payload)===null||r===void 0?void 0:r.pull_request)===null||i===void 0?void 0:i.head)===null||a===void 0?void 0:a.sha)!=undefined){c.sha=c.payload.pull_request.head.sha}}return c}function getContextFromGit(){return d(this,void 0,void 0,(function*(){return yield b.Git.context()}))}},17972:function(r,i,a){"use strict";var c=this&&this.__createBinding||(Object.create?function(r,i,a,c){if(c===Line truncated
|
||||
var c=a(73837).inherits;var p=a(25445).ZipArchiveOutputStream;var l=a(25445).ZipArchiveEntry;var d=a(82072);var u=r.exports=function(r){if(!(this instanceof u)){return new u(r)}r=this.options=r||{};r.zlib=r.zlib||{};p.call(this,r);if(typeof r.level==="number"&&r.level>=0){r.zlib.level=r.level;delete r.level}if(!r.forceZip64&&typeof r.zlib.level==="number"&&r.zlib.level===0){r.store=true}r.namePrependSlash=r.namePrependSlash||false;if(r.comment&&r.comment.length>0){this.setComment(r.comment)}};c(u,p);u.prototype._normalizeFileData=function(r){r=d.defaults(r,{type:"file",name:null,namePrependSlash:this.options.namePrependSlash,linkname:null,date:null,mode:null,store:this.options.store,comment:""});var i=r.type==="directory";var a=r.type==="symlink";if(r.name){r.name=d.sanitizePath(r.name);if(!a&&r.name.slice(-1)==="/"){i=true;r.type="directory"}else if(i){r.name+="/"}}if(i||a){r.store=true}r.date=d.dateify(r.date);return r};u.prototype.entry=function(r,i,a){if(typeof a!=="function"){a=this._emitErrorCallback.bind(this)}i=this._normalizeFileData(i);if(i.type!=="file"&&i.type!=="directory"&&i.type!=="symlink"){a(new Error(i.type+" entries not currently supported"));return}if(typeof i.name!=="string"||i.name.length===0){a(new Error("entry name must be a non-empty string value"));return}if(i.type==="symlink"&&typeof i.linkname!=="string"){a(new Error("entry linkname must be a non-empty string value when type equals symlink"));return}var c=new l(i.name);c.setTime(i.date,this.options.forceLocalTime);if(i.namePrependSlash){c.setName(i.name,true)}if(i.store){c.setMethod(0)}if(i.comment.length>0){c.setComment(i.comment)}if(i.type==="symlink"&&typeof i.mode!=="number"){i.mode=40960}if(typeof i.mode==="number"){if(i.type==="symlink"){i.mode|=40960}c.setUnixMode(i.mode)}if(i.type==="symlink"&&typeof i.linkname==="string"){r=Buffer.from(i.linkname)}return p.prototype.entry.call(this,c,r,a)};u.prototype.finalize=function(){this.finish()}},98954:function(r,i,a){"use strict";var c=this&&this.__createBinding||(Object.create?function(r,i,a,c){if(c===undefined)c=a;var p=Object.getOwnPropertyDescriptor(i,a);if(!p||("get"in p?!i.__esModule:p.writable||p.configurable)){p={enumerable:true,get:function(){return i[a]}}}Object.defineProperty(r,c,p)}:function(r,i,a,c){if(c===undefined)c=a;r[c]=i[a]});var p=this&&this.__setModuleDefault||(Object.create?function(r,i){Object.defineProperty(r,"default",{enumerable:true,value:i})}:function(r,i){r["default"]=i});var l=this&&this.__importStar||function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a in r)if(a!=="default"&&Object.prototype.hasOwnProperty.call(r,a))c(i,r,a);p(i,r);return i};var d=this&&this.__awaiter||function(r,i,a,c){function adopt(r){return r instanceof a?r:new a((function(i){i(r)}))}return new(a||(a=Promise))((function(a,p){function fulfilled(r){try{step(c.next(r))}catch(r){p(r)}}function rejected(r){try{step(c["throw"](r))}catch(r){p(r)}}function step(r){r.done?a(r.value):adopt(r.value).then(fulfilled,rejected)}step((c=c.apply(r,i||[])).next())}))};Object.defineProperty(i,"__esModule",{value:true});i.getContext=i.ContextSource=i.getInputs=void 0;const u=l(a(42186));const A=a(28662);const b=a(26074);const h=a(6276);function getInputs(){return{context:u.getInput("context")||g.workflow,images:A.Util.getInputList("images",{ignoreComma:true,comment:"#"}),tags:A.Util.getInputList("tags",{ignoreComma:true,comment:"#"}),flavor:A.Util.getInputList("flavor",{ignoreComma:true,comment:"#"}),labels:A.Util.getInputList("labels",{ignoreComma:true,comment:"#"}),annotations:A.Util.getInputList("annotations",{ignoreComma:true,comment:"#"}),sepTags:u.getInput("sep-tags",{trimWhitespace:false})||`\n`,sepLabels:u.getInput("sep-labels",{trimWhitespace:false})||`\n`,sepAnnotations:u.getInput("sep-annotations",{trimWhitespace:false})||`\n`,bakeTarget:u.getInput("bake-target")||`docker-metadata-action`,githubToken:u.getInput("github-token")}}i.getInputs=getInputs;var g;(function(r){r["workflow"]="workflow";r["git"]="git"})(g||(i.ContextSource=g={}));function getContext(r){return d(this,void 0,void 0,(function*(){switch(r){case g.workflow:return getContextFromWorkflow();case g.git:return yield getContextFromGit();default:throw new Error(`Invalid context source: ${r}`)}}))}i.getContext=getContext;function getContextFromWorkflow(){var r,i,a;const c=h.GitHub.context;if(/pull_request_target/.test(c.eventName)){c.ref=`refs/pull/${c.payload.number}/merge`}if(/true/i.test(process.env.DOCKER_METADATA_PR_HEAD_SHA||"")){if((/pull_request/.test(c.eventName)||/pull_request_target/.test(c.eventName))&&((a=(i=(r=c.payload)===null||r===void 0?void 0:r.pull_request)===null||i===void 0?void 0:i.head)===null||a===void 0?void 0:a.sha)!=undefined){c.sha=c.payload.pull_request.head.sha}}return c}function getContextFromGit(){return d(this,void 0,void 0,(function*(){return yield b.Git.context()}))}},17972:function(r,i,a){"use strict";var c=this&&this.__createBinding||(Object.create?function(r,i,a,c){if(c===Line truncated
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","names":["__createBinding","this","Object","create","o","m","k","k2","undefined","desc","getOwnPropertyDescriptor","__esModule","writable","configurable","enumerable","get","defineProperty","__exportStar","exports","p","prototype","hasOwnProperty","call","value","client_1","__webpack_require__","client","DefaultArtifactClient","Timestamp","runtime_1","runtime_2","runtime_3","runtime_4","runtime_5","runtime_6","runtime_7","Timestamp$Type","MessageType","constructor","super","no","name","kind","T","now","msg","ms","Date","seconds","PbLong","from","Math","floor","toString","nanos","toDate","message","toNumber","ceil","fromDate","date","getTime","internalJsonWrite","options","parse","Error","z","nanosStr","substring","toISOString","replace","internalJsonRead","json","target","typeofJsonValue","matches","match","Number","isNaN","globalThis","parseInt","repeat","length","MESSAGE_TYPE","reflectionMergePartial","internalBinaryRead","reader","end","pos","fieldNo","wireType","tag","int64","int32","u","readUnknownField","typeName","d","skip","UnknownFieldHandler","onRead","internalBinaryWrite","writer","WireType","Varint","writeUnknownFields","onWrite","BytesValue","StringValue","BoolValue","UInt32Value","Int32Value","UInt64Value","Int64Value","FloatValue","DoubleValue","DoubleValue$Type","refJsonWriter","scalar","refJsonReader","double","Bit64","FloatValue$Type","float","Bit32","Int64Value$Type","ScalarType","INT64","LongType","STRING","UInt64Value$Type","UINT64","uint64","Int32Value$Type","UInt32Value$Type","uint32","BoolValue$Type","bool","StringValue$Type","string","LengthDelimited","BytesValue$Type","Uint8Array","bytes","ArtifactService","DeleteArtifactResponse","DeleteArtifactRequest","GetSignedArtifactURLResponse","GetSignedArtifactURLRequest","ListArtifactsResponse_MonolithArtifact","ListArtifactsResponse","ListArtifactsRequest","FinalizeArtifactResponse","FinalizeArtifactRequest","CreateArtifactResponse","CreateArtifactRequest","runtime_rpc_1","wrappers_1","wrappers_2","timestamp_1","CreateArtifactRequest$Type","workflowRunBackendId","workflowJobRunBackendId","version","expiresAt","fork","join","CreateArtifactResponse$Type","ok","signedUploadUrl","FinalizeArtifactRequest$Type","size","hash","FinalizeArtifactResponse$Type","artifactId","ListArtifactsRequest$Type","nameFilter","idFilter","ListArtifactsResponse$Type","artifacts","push","i","ListArtifactsResponse_MonolithArtifact$Type","databaseId","createdAt","GetSignedArtifactURLRequest$Type","GetSignedArtifactURLResponse$Type","signedUrl","DeleteArtifactRequest$Type","DeleteArtifactResponse$Type","ServiceType","I","O","__awaiter","thisArg","_arguments","P","generator","adopt","resolve","Promise","reject","fulfilled","step","next","e","rejected","result","done","then","apply","createArtifactServiceServer","ArtifactServiceMethodList","ArtifactServiceMethod","ArtifactServiceClientProtobuf","ArtifactServiceClientJSON","twirp_ts_1","artifact_1","rpc","CreateArtifact","bind","FinalizeArtifact","ListArtifacts","GetSignedArtifactURL","DeleteArtifact","request","data","toJson","useProtoFieldName","emitDefaultValues","promise","fromJson","ignoreUnknownFields","toBinary","fromBinary","service","TwirpServer","packageName","serviceName","methodList","matchRoute","matchArtifactServiceRoute","method","events","ctx","interceptors","assign","methodName","onMatch","handleArtifactServiceCreateArtifactRequest","handleArtifactServiceFinalizeArtifactRequest","handleArtifactServiceListArtifactsRequest","handleArtifactServiceGetSignedArtifactURLRequest","handleArtifactServiceDeleteArtifactRequest","onNotFound","TwirpError","TwirpErrorCode","BadRoute","contentType","TwirpContentType","JSON","handleArtifactServiceCreateArtifactJSON","Protobuf","handleArtifactServiceCreateArtifactProtobuf","handleArtifactServiceFinalizeArtifactJSON","handleArtifactServiceFinalizeArtifactProtobuf","handleArtifactServiceListArtifactsJSON","handleArtifactServiceListArtifactsProtobuf","handleArtifactServiceGetSignedArtifactURLJSON","handleArtifactServiceGetSignedArtifactURLProtobuf","handleArtifactServiceDeleteArtifactJSON","handleArtifactServiceDeleteArtifactProtobuf","response","body","Malformed","withCause","interceptor","chainInterceptors","inputReq","stringify","Buffer","__rest","s","t","indexOf","getOwnPropertySymbols","propertyIsEnumerable","core_1","config_1","upload_artifact_1","download_artifact_1","delete_artifact_1","get_artifact_1","list_artifacts_1","errors_1","uploadArtifact","files","rootDirectory","isGhes","GHESNotSupportedError","error","warning","downloadArtifact","findBy","repositoryOwner","repositoryName","token","downloadOptions","downloadArtifactPublic","downloadArtifactInternal","listArtifacts","workflowRunId","listArtifactsPublic","latest","listArtifactsInternal","getArtifact","artifactName","getArtifactPublic","getArtifactInternal","deleteArtifact","deleteArtifactPublic","deleteArtifactInternal","github_1","user_agent_1","retry_options_1","utils_1","Line truncated
|
||||
{"version":3,"file":"index.js","names":["__createBinding","this","Object","create","o","m","k","k2","undefined","desc","getOwnPropertyDescriptor","__esModule","writable","configurable","enumerable","get","defineProperty","__exportStar","exports","p","prototype","hasOwnProperty","call","value","client_1","__webpack_require__","client","DefaultArtifactClient","Timestamp","runtime_1","runtime_2","runtime_3","runtime_4","runtime_5","runtime_6","runtime_7","Timestamp$Type","MessageType","constructor","super","no","name","kind","T","now","msg","ms","Date","seconds","PbLong","from","Math","floor","toString","nanos","toDate","message","toNumber","ceil","fromDate","date","getTime","internalJsonWrite","options","parse","Error","z","nanosStr","substring","toISOString","replace","internalJsonRead","json","target","typeofJsonValue","matches","match","Number","isNaN","globalThis","parseInt","repeat","length","MESSAGE_TYPE","reflectionMergePartial","internalBinaryRead","reader","end","pos","fieldNo","wireType","tag","int64","int32","u","readUnknownField","typeName","d","skip","UnknownFieldHandler","onRead","internalBinaryWrite","writer","WireType","Varint","writeUnknownFields","onWrite","BytesValue","StringValue","BoolValue","UInt32Value","Int32Value","UInt64Value","Int64Value","FloatValue","DoubleValue","DoubleValue$Type","refJsonWriter","scalar","refJsonReader","double","Bit64","FloatValue$Type","float","Bit32","Int64Value$Type","ScalarType","INT64","LongType","STRING","UInt64Value$Type","UINT64","uint64","Int32Value$Type","UInt32Value$Type","uint32","BoolValue$Type","bool","StringValue$Type","string","LengthDelimited","BytesValue$Type","Uint8Array","bytes","ArtifactService","DeleteArtifactResponse","DeleteArtifactRequest","GetSignedArtifactURLResponse","GetSignedArtifactURLRequest","ListArtifactsResponse_MonolithArtifact","ListArtifactsResponse","ListArtifactsRequest","FinalizeArtifactResponse","FinalizeArtifactRequest","CreateArtifactResponse","CreateArtifactRequest","runtime_rpc_1","wrappers_1","wrappers_2","timestamp_1","CreateArtifactRequest$Type","workflowRunBackendId","workflowJobRunBackendId","version","expiresAt","fork","join","CreateArtifactResponse$Type","ok","signedUploadUrl","FinalizeArtifactRequest$Type","size","hash","FinalizeArtifactResponse$Type","artifactId","ListArtifactsRequest$Type","nameFilter","idFilter","ListArtifactsResponse$Type","artifacts","push","i","ListArtifactsResponse_MonolithArtifact$Type","databaseId","createdAt","GetSignedArtifactURLRequest$Type","GetSignedArtifactURLResponse$Type","signedUrl","DeleteArtifactRequest$Type","DeleteArtifactResponse$Type","ServiceType","I","O","__awaiter","thisArg","_arguments","P","generator","adopt","resolve","Promise","reject","fulfilled","step","next","e","rejected","result","done","then","apply","createArtifactServiceServer","ArtifactServiceMethodList","ArtifactServiceMethod","ArtifactServiceClientProtobuf","ArtifactServiceClientJSON","twirp_ts_1","artifact_1","rpc","CreateArtifact","bind","FinalizeArtifact","ListArtifacts","GetSignedArtifactURL","DeleteArtifact","request","data","toJson","useProtoFieldName","emitDefaultValues","promise","fromJson","ignoreUnknownFields","toBinary","fromBinary","service","TwirpServer","packageName","serviceName","methodList","matchRoute","matchArtifactServiceRoute","method","events","ctx","interceptors","assign","methodName","onMatch","handleArtifactServiceCreateArtifactRequest","handleArtifactServiceFinalizeArtifactRequest","handleArtifactServiceListArtifactsRequest","handleArtifactServiceGetSignedArtifactURLRequest","handleArtifactServiceDeleteArtifactRequest","onNotFound","TwirpError","TwirpErrorCode","BadRoute","contentType","TwirpContentType","JSON","handleArtifactServiceCreateArtifactJSON","Protobuf","handleArtifactServiceCreateArtifactProtobuf","handleArtifactServiceFinalizeArtifactJSON","handleArtifactServiceFinalizeArtifactProtobuf","handleArtifactServiceListArtifactsJSON","handleArtifactServiceListArtifactsProtobuf","handleArtifactServiceGetSignedArtifactURLJSON","handleArtifactServiceGetSignedArtifactURLProtobuf","handleArtifactServiceDeleteArtifactJSON","handleArtifactServiceDeleteArtifactProtobuf","response","body","Malformed","withCause","interceptor","chainInterceptors","inputReq","stringify","Buffer","__rest","s","t","indexOf","getOwnPropertySymbols","propertyIsEnumerable","core_1","config_1","upload_artifact_1","download_artifact_1","delete_artifact_1","get_artifact_1","list_artifacts_1","errors_1","uploadArtifact","files","rootDirectory","isGhes","GHESNotSupportedError","error","warning","downloadArtifact","findBy","repositoryOwner","repositoryName","token","downloadOptions","downloadArtifactPublic","downloadArtifactInternal","listArtifacts","workflowRunId","listArtifactsPublic","latest","listArtifactsInternal","getArtifact","artifactName","getArtifactPublic","getArtifactInternal","deleteArtifact","deleteArtifactPublic","deleteArtifactInternal","github_1","user_agent_1","retry_options_1","utils_1","Line truncated
|
||||
+18
-2
@@ -14,6 +14,8 @@ import * as icl from './image';
|
||||
import * as tcl from './tag';
|
||||
import * as fcl from './flavor';
|
||||
|
||||
const defaultShortShaLength = 12;
|
||||
|
||||
export interface Version {
|
||||
main: string | undefined;
|
||||
partial: string[];
|
||||
@@ -307,7 +309,7 @@ export class Meta {
|
||||
|
||||
let val = this.context.sha;
|
||||
if (tag.attrs['format'] === tcl.ShaFormat.Short) {
|
||||
val = this.context.sha.substring(0, 7);
|
||||
val = Meta.shortSha(this.context.sha);
|
||||
}
|
||||
|
||||
const vraw = this.setValue(val, tag);
|
||||
@@ -373,7 +375,7 @@ export class Meta {
|
||||
return context.ref.replace(/^refs\/tags\//g, '');
|
||||
},
|
||||
sha: function () {
|
||||
return context.sha.substring(0, 7);
|
||||
return Meta.shortSha(context.sha);
|
||||
},
|
||||
base_ref: function () {
|
||||
if (/^refs\/tags\//.test(context.ref) && context.payload?.base_ref != undefined) {
|
||||
@@ -593,4 +595,18 @@ export class Meta {
|
||||
private static sanitizeTag(tag: string): string {
|
||||
return tag.replace(/[^a-zA-Z0-9._-]+/g, '-');
|
||||
}
|
||||
|
||||
private static shortSha(sha: string): string {
|
||||
let shortShaLength = defaultShortShaLength;
|
||||
if (process.env.DOCKER_METADATA_SHORT_SHA_LENGTH) {
|
||||
if (isNaN(Number(process.env.DOCKER_METADATA_SHORT_SHA_LENGTH))) {
|
||||
throw new Error(`DOCKER_METADATA_SHORT_SHA_LENGTH is not a valid number: ${process.env.DOCKER_METADATA_SHORT_SHA_LENGTH}`);
|
||||
}
|
||||
shortShaLength = Number(process.env.DOCKER_METADATA_SHORT_SHA_LENGTH);
|
||||
}
|
||||
if (shortShaLength >= sha.length) {
|
||||
return sha;
|
||||
}
|
||||
return sha.substring(0, shortShaLength);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user