Compare commits

..

No commits in common. "369eb591f429131d6889c46b94e711f089e6ca96" and "115662203e5f4c9b240a57397f721baaab82a488" have entirely different histories.

8 changed files with 88 additions and 112 deletions

View File

@ -45,7 +45,6 @@ ___
* [`{{base_ref}}`](#base_ref) * [`{{base_ref}}`](#base_ref)
* [`{{is_default_branch}}`](#is_default_branch) * [`{{is_default_branch}}`](#is_default_branch)
* [`{{date '<format>' tz='<timezone>'}}`](#date-format-tztimezone) * [`{{date '<format>' tz='<timezone>'}}`](#date-format-tztimezone)
* [`{{commit_date '<format>' tz='<timezone>'}}`](#commit_date-format-tztimezone)
* [Major version zero](#major-version-zero) * [Major version zero](#major-version-zero)
* [JSON output object](#json-output-object) * [JSON output object](#json-output-object)
* [Overwrite labels and annotations](#overwrite-labels-and-annotations) * [Overwrite labels and annotations](#overwrite-labels-and-annotations)
@ -362,9 +361,9 @@ So it can be used with our [Docker Build Push action](https://github.com/docker/
### environment variables ### environment variables
| Name | Type | Description | | 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_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_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`) | | `DOCKER_METADATA_ANNOTATIONS_LEVELS` | String | Comma separated list of annotations levels to set for annotations output separated (default `manifest`) |
## `context` input ## `context` input
@ -725,9 +724,9 @@ tags: |
``` ```
Output Git short commit (or long if specified) as Docker tag like Output Git short commit (or long if specified) as Docker tag like
`sha-860c190`. `sha-860c1904a1ce`.
By default, the length of the short commit SHA is `7` characters. You can By default, the length of the short commit SHA is `12` characters. You can
increase this length for larger repositories by setting the increase this length for larger repositories by setting the
[`DOCKER_METADATA_SHORT_SHA_LENGTH` environment variable](#environment-variables): [`DOCKER_METADATA_SHORT_SHA_LENGTH` environment variable](#environment-variables):
@ -742,7 +741,7 @@ increase this length for larger repositories by setting the
tags: | tags: |
type=sha type=sha
env: env:
DOCKER_METADATA_SHORT_SHA_LENGTH: 12 DOCKER_METADATA_SHORT_SHA_LENGTH: 16
``` ```
Extended attributes and default values: Extended attributes and default values:
@ -892,14 +891,13 @@ Default `tz` is UTC.
#### `{{commit_date '<format>' tz='<timezone>'}}` #### `{{commit_date '<format>' tz='<timezone>'}}`
Returns the date when the current git commit is committed, rendered by its Returns the date when current git commit is committed.
[moment format](https://momentjs.com/docs/#/displaying/format/). It falls back rendered by its [moment format](https://momentjs.com/docs/#/displaying/format/).
to the current date if the commit date is not available.
Default `tz` is UTC. Default `tz` is UTC.
| Expression | Output example | | Expression | Output example |
|-----------------------------------------------------|-----------------------------------------| |----------------------------------------------|-----------------------------------------|
| `{{commit_date 'YYYYMMDD'}}` | `20200110` | | `{{commit_date 'YYYYMMDD'}}` | `20200110` |
| `{{commit_date 'dddd, MMMM Do YYYY, h:mm:ss a'}}` | `Friday, January 10th 2020, 3:25:50 pm` | | `{{commit_date 'dddd, MMMM Do YYYY, h:mm:ss a'}}` | `Friday, January 10th 2020, 3:25:50 pm` |
| `{{commit_date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}}` | `20200110-093000` | | `{{commit_date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}}` | `20200110-093000` |

View File

@ -205,19 +205,5 @@ export const context = {
}; };
export const getOctokit = jest.fn(() => ({ export const getOctokit = jest.fn(() => ({
rest: { request: () => Promise.resolve({data: {committer: {date: '2024-11-13T13:42:28Z'}}})
repos: {
getCommit: jest.fn(() =>
Promise.resolve({
data: {
commit: {
committer: {
date: '2024-11-13T13:42:28Z'
}
}
}
})
)
}
}
})); }));

View File

@ -5,9 +5,9 @@ import * as path from 'path';
import {Context} from '@actions/github/lib/context'; import {Context} from '@actions/github/lib/context';
import {Git} from '@docker/actions-toolkit/lib/git'; import {Git} from '@docker/actions-toolkit/lib/git';
import {GitHub} from '@docker/actions-toolkit/lib/github'; import {GitHub} from '@docker/actions-toolkit/lib/github';
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
import {ContextSource, getContext, getInputs, Inputs} from '../src/context'; import {ContextSource, getContext, getInputs, Inputs} from '../src/context';
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
const toolkit = new Toolkit({githubToken: 'fake-github-token'}); const toolkit = new Toolkit({githubToken: 'fake-github-token'});

View File

@ -2,11 +2,10 @@ import {beforeEach, describe, expect, jest, test} from '@jest/globals';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as dotenv from 'dotenv'; import * as dotenv from 'dotenv';
import {Context} from '@actions/github/lib/context';
import {GitHub} from '@docker/actions-toolkit/lib/github'; import {GitHub} from '@docker/actions-toolkit/lib/github';
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit'; import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
import {GitHubRepo} from '@docker/actions-toolkit/lib/types/github'; import {GitHubRepo} from '@docker/actions-toolkit/lib/types/github';
import {Context} from '@actions/github/lib/context';
import {ContextSource, getContext, getInputs, Inputs} from '../src/context'; import {ContextSource, getContext, getInputs, Inputs} from '../src/context';
import {Meta, Version} from '../src/meta'; import {Meta, Version} from '../src/meta';
@ -319,14 +318,14 @@ describe('push', () => {
} as Inputs, } as Inputs,
{ {
main: 'dev', main: 'dev',
partial: ['sha-860c190'], partial: ['sha-860c1904a1ce'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:dev', 'org/app:dev',
'org/app:sha-860c190', 'org/app:sha-860c1904a1ce',
'ghcr.io/user/app:dev', '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", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -352,14 +351,14 @@ describe('push', () => {
} as Inputs, } as Inputs,
{ {
main: 'edge', main: 'edge',
partial: ['sha-2665741'], partial: ['sha-266574110acf'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:edge', 'org/app:edge',
'org/app:sha-2665741', 'org/app:sha-266574110acf',
'ghcr.io/user/app:edge', '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", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -385,14 +384,14 @@ describe('push', () => {
} as Inputs, } as Inputs,
{ {
main: 'edge', main: 'edge',
partial: ['sha-860c190'], partial: ['sha-860c1904a1ce'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:edge', 'org/app:edge',
'org/app:sha-860c190', 'org/app:sha-860c1904a1ce',
'ghcr.io/user/app:edge', '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", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -417,13 +416,13 @@ describe('push', () => {
], ],
} as Inputs, } as Inputs,
{ {
main: 'sha-2665741', main: 'sha-266574110acf',
partial: [], partial: [],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:sha-2665741', 'org/app:sha-266574110acf',
'ghcr.io/user/app:sha-2665741' 'ghcr.io/user/app:sha-266574110acf'
], ],
[ [
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -433,7 +432,7 @@ describe('push', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/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 undefined
], ],
@ -448,13 +447,13 @@ describe('push', () => {
], ],
} as Inputs, } as Inputs,
{ {
main: 'sha-983315b', main: 'sha-983315b5e8d4',
partial: [], partial: [],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:sha-983315b', 'org/app:sha-983315b5e8d4',
'ghcr.io/user/app:sha-983315b' 'ghcr.io/user/app:sha-983315b5e8d4'
], ],
[ [
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -464,7 +463,7 @@ describe('push', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/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 undefined
], ],
@ -1356,17 +1355,17 @@ describe('tag', () => {
} as Inputs, } as Inputs,
{ {
main: '1.0.0', main: '1.0.0',
partial: ['1.0', 'sha-860c190'], partial: ['1.0', 'sha-860c1904a1ce'],
latest: true latest: true
} as Version, } as Version,
[ [
'org/app:1.0.0', 'org/app:1.0.0',
'org/app:1.0', 'org/app:1.0',
'org/app:sha-860c190', 'org/app:sha-860c1904a1ce',
'org/app:latest', 'org/app:latest',
'ghcr.io/user/app:1.0.0', 'ghcr.io/user/app:1.0.0',
'ghcr.io/user/app:1.0', 'ghcr.io/user/app:1.0',
'ghcr.io/user/app:sha-860c190', 'ghcr.io/user/app:sha-860c1904a1ce',
'ghcr.io/user/app:latest' 'ghcr.io/user/app:latest'
], ],
[ [
@ -1396,17 +1395,17 @@ describe('tag', () => {
} as Inputs, } as Inputs,
{ {
main: '1.0.0', main: '1.0.0',
partial: ['1.0', 'sha-860c190'], partial: ['1.0', 'sha-860c1904a1ce'],
latest: true latest: true
} as Version, } as Version,
[ [
'org/app:1.0.0', 'org/app:1.0.0',
'org/app:1.0', 'org/app:1.0',
'org/app:sha-860c190', 'org/app:sha-860c1904a1ce',
'org/app:latest', 'org/app:latest',
'ghcr.io/user/app:1.0.0', 'ghcr.io/user/app:1.0.0',
'ghcr.io/user/app:1.0', 'ghcr.io/user/app:1.0',
'ghcr.io/user/app:sha-860c190', 'ghcr.io/user/app:sha-860c1904a1ce',
'ghcr.io/user/app:latest' 'ghcr.io/user/app:latest'
], ],
[ [
@ -1438,17 +1437,17 @@ describe('tag', () => {
} as Inputs, } as Inputs,
{ {
main: '1.0.0-dev', main: '1.0.0-dev',
partial: ['1.0', 'sha-860c190-dev'], partial: ['1.0', 'sha-860c1904a1ce-dev'],
latest: true latest: true
} as Version, } as Version,
[ [
'org/app:1.0.0-dev', 'org/app:1.0.0-dev',
'org/app:1.0', 'org/app:1.0',
'org/app:sha-860c190-dev', 'org/app:sha-860c1904a1ce-dev',
'org/app:latest', 'org/app:latest',
'ghcr.io/user/app:1.0.0-dev', 'ghcr.io/user/app:1.0.0-dev',
'ghcr.io/user/app:1.0', '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' 'ghcr.io/user/app:latest'
], ],
[ [
@ -1475,16 +1474,16 @@ describe('tag', () => {
] ]
} as Inputs, } as Inputs,
{ {
main: 'v1.1.1-860c190-foo', main: 'v1.1.1-860c1904a1ce-foo',
partial: [ partial: [
'master-foo' 'master-foo'
], ],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:v1.1.1-860c190-foo', 'org/app:v1.1.1-860c1904a1ce-foo',
'org/app:master-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' 'ghcr.io/user/app:master-foo'
], ],
[ [
@ -1495,7 +1494,7 @@ describe('tag', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/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 undefined
], ],
@ -2349,14 +2348,14 @@ describe('pr', () => {
} as Inputs, } as Inputs,
{ {
main: 'pr-15', main: 'pr-15',
partial: ['sha-a9c8c58'], partial: ['sha-a9c8c5828b91'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:pr-15', 'org/app:pr-15',
'org/app:sha-a9c8c58', 'org/app:sha-a9c8c5828b91',
'ghcr.io/user/app:pr-15', '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", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -2381,14 +2380,14 @@ describe('pr', () => {
] ]
} as Inputs, } as Inputs,
{ {
main: 'sha-a9c8c58', main: 'sha-a9c8c5828b91',
partial: ['pr-15'], partial: ['pr-15'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:sha-a9c8c58', 'org/app:sha-a9c8c5828b91',
'org/app:pr-15', 'org/app:pr-15',
'ghcr.io/user/app:sha-a9c8c58', 'ghcr.io/user/app:sha-a9c8c5828b91',
'ghcr.io/user/app:pr-15' 'ghcr.io/user/app:pr-15'
], ],
[ [
@ -2399,7 +2398,7 @@ describe('pr', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/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 undefined
], ],
@ -2482,14 +2481,14 @@ describe('pr', () => {
] ]
} as Inputs, } as Inputs,
{ {
main: 'sha-2665741', main: 'sha-266574110acf',
partial: ['pr-15'], partial: ['pr-15'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:sha-2665741', 'org/app:sha-266574110acf',
'org/app:pr-15', 'org/app:pr-15',
'ghcr.io/user/app:sha-2665741', 'ghcr.io/user/app:sha-266574110acf',
'ghcr.io/user/app:pr-15' 'ghcr.io/user/app:pr-15'
], ],
[ [
@ -2500,7 +2499,7 @@ describe('pr', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/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 undefined
], ],
@ -2554,14 +2553,14 @@ describe('pr', () => {
{ {
main: 'pr-15', main: 'pr-15',
partial: [ partial: [
'sha-2665741', 'sha-266574110acf',
'sha-266574110acf203503badf966df2ea24b5d732d7' 'sha-266574110acf203503badf966df2ea24b5d732d7'
], ],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:pr-15', 'org/app:pr-15',
'org/app:sha-2665741', 'org/app:sha-266574110acf',
'org/app:sha-266574110acf203503badf966df2ea24b5d732d7' 'org/app:sha-266574110acf203503badf966df2ea24b5d732d7'
], ],
[ [
@ -2735,14 +2734,14 @@ describe('pr-head-sha', () => {
} as Inputs, } as Inputs,
{ {
main: 'pr-15', main: 'pr-15',
partial: ['sha-3370e22'], partial: ['sha-3370e228f220'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:pr-15', 'org/app:pr-15',
'org/app:sha-3370e22', 'org/app:sha-3370e228f220',
'ghcr.io/user/app:pr-15', '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", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -2766,14 +2765,14 @@ describe('pr-head-sha', () => {
] ]
} as Inputs, } as Inputs,
{ {
main: 'sha-3370e22', main: 'sha-3370e228f220',
partial: ['pr-15'], partial: ['pr-15'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:sha-3370e22', 'org/app:sha-3370e228f220',
'org/app:pr-15', 'org/app:pr-15',
'ghcr.io/user/app:sha-3370e22', 'ghcr.io/user/app:sha-3370e228f220',
'ghcr.io/user/app:pr-15' 'ghcr.io/user/app:pr-15'
], ],
[ [
@ -2784,7 +2783,7 @@ describe('pr-head-sha', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-3370e22" "org.opencontainers.image.version=sha-3370e228f220"
] ]
], ],
[ [
@ -2864,14 +2863,14 @@ describe('pr-head-sha', () => {
] ]
} as Inputs, } as Inputs,
{ {
main: 'sha-3370e22', main: 'sha-3370e228f220',
partial: ['pr-15'], partial: ['pr-15'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:sha-3370e22', 'org/app:sha-3370e228f220',
'org/app:pr-15', 'org/app:pr-15',
'ghcr.io/user/app:sha-3370e22', 'ghcr.io/user/app:sha-3370e228f220',
'ghcr.io/user/app:pr-15' 'ghcr.io/user/app:pr-15'
], ],
[ [
@ -2882,7 +2881,7 @@ describe('pr-head-sha', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sha-3370e22" "org.opencontainers.image.version=sha-3370e228f220"
] ]
], ],
[ [
@ -2934,14 +2933,14 @@ describe('pr-head-sha', () => {
{ {
main: 'pr-15', main: 'pr-15',
partial: [ partial: [
'sha-3370e22', 'sha-3370e228f220',
'sha-3370e228f2209994d57af4427fe64e71bb79ac96' 'sha-3370e228f2209994d57af4427fe64e71bb79ac96'
], ],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:pr-15', 'org/app:pr-15',
'org/app:sha-3370e22', 'org/app:sha-3370e228f220',
'org/app:sha-3370e228f2209994d57af4427fe64e71bb79ac96' 'org/app:sha-3370e228f2209994d57af4427fe64e71bb79ac96'
], ],
[ [
@ -3197,14 +3196,14 @@ describe('schedule', () => {
} as Inputs, } as Inputs,
{ {
main: 'nightly', main: 'nightly',
partial: ['sha-860c190'], partial: ['sha-860c1904a1ce'],
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:nightly', 'org/app:nightly',
'org/app:sha-860c190', 'org/app:sha-860c1904a1ce',
'ghcr.io/user/app:nightly', '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", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
@ -3230,7 +3229,7 @@ describe('schedule', () => {
] ]
} as Inputs, } as Inputs,
{ {
main: 'sha-860c190', main: 'sha-860c1904a1ce',
partial: [ partial: [
'nightly', 'nightly',
'defbranch' 'defbranch'
@ -3238,10 +3237,10 @@ describe('schedule', () => {
latest: false latest: false
} as Version, } as Version,
[ [
'org/app:sha-860c190', 'org/app:sha-860c1904a1ce',
'org/app:nightly', 'org/app:nightly',
'org/app:defbranch', 'org/app:defbranch',
'ghcr.io/user/app:sha-860c190', 'ghcr.io/user/app:sha-860c1904a1ce',
'ghcr.io/user/app:nightly', 'ghcr.io/user/app:nightly',
'ghcr.io/user/app:defbranch' 'ghcr.io/user/app:defbranch'
], ],
@ -3253,7 +3252,7 @@ describe('schedule', () => {
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.url=https://github.com/octocat/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 undefined
], ],

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -119,18 +119,11 @@ async function getCommitDateFromWorkflow(sha: string, toolkit: Toolkit): Promise
} }
// fallback to github api for commit date // fallback to github api for commit date
try { const commit = await toolkit.github.octokit.request('GET /repos/{owner}/{repo}/commits/{commit_sha}', {
const commit = await toolkit.github.octokit.rest.repos.getCommit({ commit_sha: sha,
owner: GitHub.context.repo.owner, owner: GitHub.context.repo.owner,
repo: GitHub.context.repo.repo, repo: GitHub.context.repo.repo
ref: sha
}); });
if (commit.data.commit.committer?.date) {
return new Date(commit.data.commit.committer.date); return new Date(commit.data.committer.date);
}
throw new Error('Committer date not found');
} catch (error) {
core.debug(`Failed to get commit date from GitHub API: ${error.message}`);
return new Date();
}
} }

View File

@ -13,7 +13,7 @@ import * as icl from './image';
import * as tcl from './tag'; import * as tcl from './tag';
import * as fcl from './flavor'; import * as fcl from './flavor';
const defaultShortShaLength = 7; const defaultShortShaLength = 12;
export interface Version { export interface Version {
main: string | undefined; main: string | undefined;