Compare commits

..

No commits in common. "master" and "v5.6.0" have entirely different histories.

26 changed files with 7537 additions and 3682 deletions

View File

@ -31,7 +31,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Docker meta
uses: ./
@ -43,7 +43,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -80,7 +80,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -116,7 +116,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -150,7 +150,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -181,7 +181,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -204,7 +204,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -225,7 +225,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -255,7 +255,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -269,8 +269,6 @@ jobs:
images: |
${{ env.DOCKER_IMAGE }}
ghcr.io/name/app
labels: |
org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}}
tags: |
type=sha
type=raw,value=gexp-branch-{{branch}}
@ -278,14 +276,13 @@ jobs:
type=raw,value=gexp-tag-{{tag}}
type=raw,value=gexp-baseref-{{base_ref}}
type=raw,value=gexp-defbranch,enable={{is_default_branch}}
type=raw,value=gexp-notdefbranch,enable={{is_not_default_branch}}
json:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -320,7 +317,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -368,7 +365,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -393,12 +390,12 @@ jobs:
type=sha
-
name: Build
uses: docker/bake-action@v6
uses: docker/bake-action@v5
with:
files: |
./test/docker-bake.hcl
cwd://${{ steps.docker_meta.outputs.bake-file-tags }}
cwd://${{ steps.docker_meta.outputs.bake-file-labels }}
${{ steps.docker_meta.outputs.bake-file-tags }}
${{ steps.docker_meta.outputs.bake-file-labels }}
targets: |
release
@ -413,7 +410,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -431,7 +428,7 @@ jobs:
sep-tags: ${{ matrix.sep }}
-
name: Tags
uses: actions/github-script@v8
uses: actions/github-script@v7
with:
script: |
console.log(`${{ steps.meta.outputs.tags }}`);
@ -441,7 +438,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -473,38 +470,12 @@ jobs:
DOCKER_METADATA_OUTPUT_ANNOTATIONS
DOCKER_METADATA_OUTPUT_JSON
no-output-env:
runs-on: ubuntu-latest
env:
DOCKER_METADATA_SET_OUTPUT_ENV: false
steps:
-
name: Checkout
uses: actions/checkout@v6
-
name: Docker meta
id: meta
uses: ./
with:
images: |
${{ env.DOCKER_IMAGE }}
ghcr.io/name/app
labels: |
maintainer=CrazyMax
annotations: |
maintainer=Foo
-
name: No output environment variables set
shell: bash
run: |
[[ "$(printenv | grep "^DOCKER_METADATA_OUTPUT_" | wc -l)" -eq 0 ]] || exit 1
bake-annotations:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -531,12 +502,12 @@ jobs:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
-
name: Build
uses: docker/bake-action@v6
uses: docker/bake-action@v5
with:
files: |
./test/docker-bake.hcl
cwd://${{ steps.docker_meta.outputs.bake-file-tags }}
cwd://${{ steps.docker_meta.outputs.bake-file-annotations }}
${{ steps.docker_meta.outputs.bake-file-tags }}
${{ steps.docker_meta.outputs.bake-file-annotations }}
targets: |
release
@ -545,7 +516,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -566,12 +537,12 @@ jobs:
name: Print envs
run: env|sort
bake-path-context:
bake-cwd:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -583,13 +554,13 @@ jobs:
uses: ./
-
name: Build
uses: docker/bake-action@v6
uses: docker/bake-action@v5
with:
source: .
source: "{{defaultContext}}"
files: |
./test/docker-bake.hcl
${{ steps.docker_meta.outputs.bake-file-tags }}
${{ steps.docker_meta.outputs.bake-file-labels }}
cwd://${{ steps.docker_meta.outputs.bake-file-tags }}
cwd://${{ steps.docker_meta.outputs.bake-file-labels }}
targets: |
release
@ -604,7 +575,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@ -628,7 +599,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Dump context
uses: crazy-max/ghaction-dump-context@v2

View File

@ -1,17 +0,0 @@
name: pr-assign-author
permissions:
contents: read
on:
pull_request_target:
types:
- opened
- reopened
jobs:
run:
uses: crazy-max/.github/.github/workflows/pr-assign-author.yml@1b673f36fad86812f538c1df9794904038a23cbf
permissions:
contents: read
pull-requests: write

View File

@ -15,7 +15,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Publish
uses: actions/publish-immutable-action@v0.0.4

View File

@ -17,16 +17,15 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: Test
uses: docker/bake-action@v6
uses: docker/bake-action@v5
with:
source: .
targets: test
-
name: Upload coverage
uses: codecov/codecov-action@v5
with:
files: ./coverage/clover.xml
file: ./coverage/clover.xml
token: ${{ secrets.CODECOV_TOKEN }}

View File

@ -15,17 +15,16 @@ jobs:
prepare:
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.generate.outputs.targets }}
targets: ${{ steps.targets.outputs.matrix }}
steps:
-
name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@v4
-
name: List targets
id: generate
uses: docker/bake-action/subaction/list-targets@v6
with:
target: validate
name: Targets matrix
id: targets
run: |
echo "matrix=$(docker buildx bake validate --print | jq -cr '.group.validate.targets')" >> $GITHUB_OUTPUT
validate:
runs-on: ubuntu-latest
@ -36,8 +35,11 @@ jobs:
matrix:
target: ${{ fromJson(needs.prepare.outputs.targets) }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Validate
uses: docker/bake-action@v6
uses: docker/bake-action@v5
with:
targets: ${{ matrix.target }}

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,3 @@
# https://yarnpkg.com/configuration/yarnrc
compressionLevel: mixed
enableGlobalCache: false
enableHardenedMode: true
logFilters:
- code: YN0013
level: discard
@ -11,7 +5,9 @@ logFilters:
level: discard
- code: YN0076
level: discard
- code: YN0086
level: discard
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

148
README.md
View File

@ -44,7 +44,6 @@ ___
* [`{{sha}}`](#sha)
* [`{{base_ref}}`](#base_ref)
* [`{{is_default_branch}}`](#is_default_branch)
* [`{{is_not_default_branch}}`](#is_not_default_branch)
* [`{{date '<format>' tz='<timezone>'}}`](#date-format-tztimezone)
* [`{{commit_date '<format>' tz='<timezone>'}}`](#commit_date-format-tztimezone)
* [Major version zero](#major-version-zero)
@ -77,7 +76,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v4
-
name: Docker meta
id: meta
@ -93,7 +92,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v6
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
@ -131,7 +130,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v4
-
name: Docker meta
id: meta
@ -153,7 +152,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v6
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
@ -207,6 +206,9 @@ jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
id: meta
@ -222,11 +224,11 @@ jobs:
type=sha
-
name: Build
uses: docker/bake-action@v6
uses: docker/bake-action@v4
with:
files: |
./docker-bake.hcl
cwd://${{ steps.meta.outputs.bake-file }}
${{ steps.meta.outputs.bake-file }}
targets: build
```
@ -269,12 +271,29 @@ similar to the previous one:
```yaml
-
name: Build
uses: docker/bake-action@v6
uses: docker/bake-action@v4
with:
files: |
./docker-bake.hcl
cwd://${{ steps.meta.outputs.bake-file-tags }}
cwd://${{ steps.meta.outputs.bake-file-labels }}
${{ steps.meta.outputs.bake-file-tags }}
${{ steps.meta.outputs.bake-file-labels }}
targets: build
```
If you're building a [remote Bake definition](https://docs.docker.com/build/bake/remote-definition/)
using a [Git context](https://github.com/docker/bake-action?tab=readme-ov-file#git-context),
you must specify the location of the metadata-only bake file using a `cwd://`
prefix:
```yaml
-
name: Build
uses: docker/bake-action@v4
with:
source: "${{ github.server_url }}/${{ github.repository }}.git#${{ github.ref }}"
files: |
./docker-bake.hcl
cwd://${{ steps.meta.outputs.bake-file }}
targets: build
```
@ -284,7 +303,6 @@ similar to the previous one:
The following inputs can be used as `step.with` keys:
> [!NOTE]
> `List` type is a newline-delimited string
> ```yaml
> labels: |
@ -300,7 +318,7 @@ The following inputs can be used as `step.with` keys:
| `tags` | List | List of [tags](#tags-input) as key-value pair attributes |
| `flavor` | List | [Flavor](#flavor-input) to apply |
| `labels` | List | List of custom labels |
| `annotations` | List | List of custom annotations |
| `annotations` | List | List of custom anntoations |
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
| `sep-annotations` | String | Separator to use for annotations output (default `\n`) |
@ -314,7 +332,6 @@ The following outputs are available:
|-------------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `version` | String | Docker image version |
| `tags` | String | Docker tags |
| `tag-names` | String | Docker tag names without image base name |
| `labels` | String | Docker labels |
| `annotations` | String | [Annotations](https://github.com/moby/buildkit/blob/master/docs/annotations.md) |
| `json` | String | JSON output of tags and labels |
@ -322,7 +339,7 @@ The following outputs are available:
| `bake-file-labels` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with labels |
| `bake-file-annotations` | File | [Bake file definition](https://docs.docker.com/build/bake/reference/) path with [annotations](https://github.com/moby/buildkit/blob/master/docs/annotations.md) |
Alternatively, each output is also exported as an environment variable when `DOCKER_METADATA_SET_OUTPUT_ENV` is `true`:
Alternatively, each output is also exported as an environment variable:
* `DOCKER_METADATA_OUTPUT_VERSION`
* `DOCKER_METADATA_OUTPUT_TAGS`
@ -336,7 +353,7 @@ Alternatively, each output is also exported as an environment variable when `DOC
So it can be used with our [Docker Build Push action](https://github.com/docker/build-push-action/):
```yaml
- uses: docker/build-push-action@v6
- uses: docker/build-push-action@v5
with:
build-args: |
DOCKER_METADATA_OUTPUT_JSON
@ -345,11 +362,10 @@ 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 `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_SET_OUTPUT_ENV` | Bool | If `true`, sets each output as an environment variable (default `true`) |
## `context` input
@ -464,7 +480,7 @@ tags: |
# handlebars
type=schedule,pattern={{date 'YYYYMMDD'}}
# handlebars with timezone
type=schedule,pattern={{date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}}
type=schedule,pattern={{date 'YYYYMMDD-hhmmss' tz='Asia/Tokyo'}}
```
Will be used on [schedule event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule).
@ -496,8 +512,6 @@ tags: |
type=semver,pattern={{version}}
# use custom value instead of git tag
type=semver,pattern={{version}},value=v1.0.0
# use custom value and match part of it
type=semver,pattern={{version}},value=p1/v1.0.0,match=v(\d.\d.\d)$
```
Will be used on a [push tag event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push)
@ -513,21 +527,18 @@ with the following expressions:
* `minor` ; minor version identifier
* `patch` ; patch version identifier
| Git tag | Pattern | Match | Output |
|------------------|-----------------------|----------------|------------------|
| `v1.2.3` | `{{raw}}` | | `v1.2.3` |
| `v1.2.3` | `{{version}}` | | `1.2.3` |
| `v1.2.3` | `{{major}}.{{minor}}` | | `1.2` |
| `v1.2.3` | `v{{major}}` | | `v1` |
| `v1.2.3` | `{{minor}}` | | `2` |
| `v1.2.3` | `{{patch}}` | | `3` |
| `p1/v1.2.3` | `{{version}}` | `v(\d.\d.\d)$` | `1.2.3` |
| `v2.0.8-beta.67` | `{{raw}}` | | `v2.0.8-beta.67` |
| `v2.0.8-beta.67` | `{{version}}` | | `2.0.8-beta.67` |
| `v2.0.8-beta.67` | `{{major}}` | | `2.0.8-beta.67`* |
| `v2.0.8-beta.67` | `{{major}}.{{minor}}` | | `2.0.8-beta.67`* |
| Git tag | Pattern | Output |
|--------------------|----------------------------------------------------------|----------------------|
| `v1.2.3` | `{{raw}}` | `v1.2.3` |
| `v1.2.3` | `{{version}}` | `1.2.3` |
| `v1.2.3` | `{{major}}.{{minor}}` | `1.2` |
| `v1.2.3` | `v{{major}}` | `v1` |
| `v1.2.3` | `{{minor}}` | `2` |
| `v1.2.3` | `{{patch}}` | `3` |
| `v2.0.8-beta.67` | `{{raw}}` | `v2.0.8-beta.67` |
| `v2.0.8-beta.67` | `{{version}}` | `2.0.8-beta.67` |
| `v2.0.8-beta.67` | `{{major}}.{{minor}}` | `2.0.8-beta.67`* |
> [!IMPORTANT]
> *Pre-release (rc, beta, alpha) will only extend `{{version}}` (or `{{raw}}`
> if specified) as tag because they are updated frequently, and contain many
> breaking changes that are (by the author's design) not yet fit for public
@ -537,7 +548,7 @@ Extended attributes and default values:
```yaml
tags: |
type=semver,enable=true,priority=900,prefix=,suffix=,pattern=,value=,match=
type=semver,enable=true,priority=900,prefix=,suffix=,pattern=,value=
```
### `type=pep440`
@ -548,8 +559,6 @@ tags: |
type=pep440,pattern={{version}}
# use custom value instead of git tag
type=pep440,pattern={{version}},value=1.0.0
# use custom value and match part of it
type=pep440,pattern={{version}},value=p1/v1.0.0,match=v(\d.\d.\d)$
```
Will be used on a [push tag event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push)
@ -565,22 +574,20 @@ with the following expressions:
* `minor` ; minor version identifier
* `patch` ; patch version identifier
| Git tag | Pattern | Match | Output |
|--------------|-----------------------|----------------|----------------|
| `1.2.3` | `{{raw}}` | | `1.2.3` |
| `1.2.3` | `{{version}}` | | `1.2.3` |
| `v1.2.3` | `{{version}}` | | `1.2.3` |
| `1.2.3` | `{{major}}.{{minor}}` | | `1.2` |
| `1.2.3` | `v{{major}}` | | `v1` |
| `v1.2.3rc2` | `{{raw}}` | | `v1.2.3rc2` |
| `1.2.3rc2` | `{{version}}` | | `1.2.3rc2` |
| `p1/v1.2.3` | `{{version}}` | `v(\d.\d.\d)$` | `1.2.3` |
| `1.2.3rc2` | `{{major}}.{{minor}}` | | `1.2.3rc2`* |
| `1.2.3post1` | `{{major}}.{{minor}}` | | `1.2.3.post1`* |
| `1.2.3beta2` | `{{major}}.{{minor}}` | | `1.2.3b2`* |
| `1.0dev4` | `{{major}}.{{minor}}` | | `1.0.dev4`* |
| Git tag | Pattern | Output |
|--------------------|----------------------------------------------------------|----------------------|
| `1.2.3` | `{{raw}}` | `1.2.3` |
| `1.2.3` | `{{version}}` | `1.2.3` |
| `v1.2.3` | `{{version}}` | `1.2.3` |
| `1.2.3` | `{{major}}.{{minor}}` | `1.2` |
| `1.2.3` | `v{{major}}` | `v1` |
| `v1.2.3rc2` | `{{raw}}` | `v1.2.3rc2` |
| `1.2.3rc2` | `{{version}}` | `1.2.3rc2` |
| `1.2.3rc2` | `{{major}}.{{minor}}` | `1.2.3rc2`* |
| `1.2.3post1` | `{{major}}.{{minor}}` | `1.2.3.post1`* |
| `1.2.3beta2` | `{{major}}.{{minor}}` | `1.2.3b2`* |
| `1.0dev4` | `{{major}}.{{minor}}` | `1.0.dev4`* |
> [!IMPORTANT]
> *dev/pre/post release will only extend `{{version}}` (or `{{raw}}` if
> specified) as tag because they are updated frequently, and contain many
> breaking changes that are (by the author's design) not yet fit for public
@ -718,9 +725,9 @@ tags: |
```
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
[`DOCKER_METADATA_SHORT_SHA_LENGTH` environment variable](#environment-variables):
@ -735,7 +742,7 @@ increase this length for larger repositories by setting the
tags: |
type=sha
env:
DOCKER_METADATA_SHORT_SHA_LENGTH: 12
DOCKER_METADATA_SHORT_SHA_LENGTH: 16
```
Extended attributes and default values:
@ -770,7 +777,6 @@ generated by default (`auto` mode) for:
* [`type=ref,event=tag`](#typeref)
* [`type=semver,pattern=...`](#typesemver)
* [`type=pep440,pattern=...`](#typepep440)
* [`type=match,pattern=...`](#typematch)
For conditionally tagging with latest for a specific branch name, e.g. if your
@ -812,8 +818,7 @@ Each tags `type` attribute has a default priority:
### Global expressions
The following [Handlebars' template](https://handlebarsjs.com/guide/) expressions
for `prefix`, `suffix`, `value` and `enable` attributes of `tags` input are
available:
for `prefix`, `suffix`, `value` and `enable` attributes are available:
```yaml
tags: |
@ -823,13 +828,6 @@ tags: |
type=raw,value=mytag-{{branch}}-{{sha}}
```
They can also be applied to `labels` and `annotations` inputs:
```yaml
labels: |
org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}}
```
#### `{{branch}}`
Returns the branch name that triggered the workflow run. Will be empty if not
@ -870,7 +868,6 @@ workflow run. Will be empty for a branch reference:
| `push` | `refs/heads/my/branch` | |
| `push tag`* | `refs/tags/v1.2.3` | `master` |
> [!IMPORTANT]
> *`base_ref` is available in the push payload but doesn't always seem to
> return the expected branch when the push tag event occurs. It's also
> [not documented in GitHub docs](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push).
@ -882,11 +879,6 @@ workflow run. Will be empty for a branch reference:
Returns `true` if the branch that triggered the workflow run is the default
one, otherwise `false`.
#### `{{is_not_default_branch}}`
Returns `true` if the branch that triggered the workflow run is not the default
one, otherwise `false`.
#### `{{date '<format>' tz='<timezone>'}}`
Returns the current date rendered by its [moment format](https://momentjs.com/docs/#/displaying/format/).
@ -945,7 +937,7 @@ that you can reuse them further in your workflow using the [`fromJSON` function]
images: name/app
-
name: Build and push
uses: docker/build-push-action@v6
uses: docker/build-push-action@v5
with:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
@ -992,7 +984,7 @@ of the `metadata-action`:
images: name/app
-
name: Build and push
uses: docker/build-push-action@v6
uses: docker/build-push-action@v5
with:
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
@ -1008,12 +1000,12 @@ The same can be done with the [`bake-action`](https://github.com/docker/bake-act
images: name/app
-
name: Build
uses: docker/bake-action@v6
uses: docker/bake-action@v4
with:
files: |
./docker-bake.hcl
cwd://${{ steps.meta.outputs.bake-file-tags }}
cwd://${{ steps.meta.outputs.bake-file-annotations }}
${{ steps.meta.outputs.bake-file-tags }}
${{ steps.meta.outputs.bake-file-annotations }}
targets: build
```
@ -1039,7 +1031,7 @@ Please consult the documentation of your registry.
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
-
name: Build and push
uses: docker/build-push-action@v6
uses: docker/build-push-action@v5
with:
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}

300
UPGRADE.md Normal file
View File

@ -0,0 +1,300 @@
# Upgrade notes
## v2 to v3
* Repository has been moved to docker org. Replace `crazy-max/ghaction-docker-meta@v2`
with `docker/metadata-action@v5`
* The default bake target has been changed: `ghaction-docker-meta` > `docker-metadata-action`
## v1 to v2
* [inputs](#inputs)
* [`tag-sha`](#tag-sha)
* [`tag-edge` / `tag-edge-branch`](#tag-edge--tag-edge-branch)
* [`tag-semver`](#tag-semver)
* [`tag-match` / `tag-match-group`](#tag-match--tag-match-group)
* [`tag-latest`](#tag-latest)
* [`tag-schedule`](#tag-schedule)
* [`tag-custom` / `tag-custom-only`](#tag-custom--tag-custom-only)
* [`label-custom`](#label-custom)
* [Basic workflow](#basic-workflow)
* [Semver workflow](#semver-workflow)
### inputs
| New | Unchanged | Removed |
|------------|-----------------|--------------------|
| `tags` | `images` | `tag-sha` |
| `flavor` | `sep-tags` | `tag-edge` |
| `labels` | `sep-labels` | `tag-edge-branch` |
| | | `tag-semver` |
| | | `tag-match` |
| | | `tag-match-group` |
| | | `tag-latest` |
| | | `tag-schedule` |
| | | `tag-custom` |
| | | `tag-custom-only` |
| | | `label-custom` |
#### `tag-sha`
```yaml
tags: |
type=sha
```
#### `tag-edge` / `tag-edge-branch`
```yaml
tags: |
# default branch
type=edge
# specify branch
type=edge,branch=main
```
#### `tag-semver`
```yaml
tags: |
type=semver,pattern={{version}}
```
#### `tag-match` / `tag-match-group`
```yaml
tags: |
type=match,pattern=v(.*),group=1
```
#### `tag-latest`
`tag-latest` is now handled through the [`flavor` input](README.md#flavor-input):
```yaml
flavor: |
latest=auto
```
See also the notes about ["latest tag" behavior](README.md#latest-tag)
#### `tag-schedule`
```yaml
tags: |
# default tag (nightly)
type=schedule
# specific pattern
type=schedule,pattern={{date 'YYYYMMDD'}}
```
#### `tag-custom` / `tag-custom-only`
```yaml
tags: |
type=raw,value=foo
type=raw,value=bar
# or
type=raw,foo
type=raw,bar
# or
foo
bar
```
#### `label-custom`
Same behavior for `labels`:
```yaml
labels: |
maintainer=CrazyMax
```
### Basic workflow
```yaml
# v1
name: ci
on:
push:
branches:
- 'master'
tags:
- 'v*'
pull_request:
branches:
- 'master'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
id: meta
uses: docker/metadata-action@v1
with:
images: name/app
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
```
```yaml
# v2
name: ci
on:
push:
branches:
- 'master'
tags:
- 'v*'
pull_request:
branches:
- 'master'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: name/app
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
```
### Semver workflow
```yaml
# v1
name: ci
on:
push:
branches:
- 'master'
tags:
- 'v*'
pull_request:
branches:
- 'master'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
id: meta
uses: docker/metadata-action@v1
with:
images: name/app
tag-semver: |
{{version}}
{{major}}.{{minor}}
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
```
```yaml
# v2
name: ci
on:
push:
branches:
- 'master'
tags:
- 'v*'
pull_request:
branches:
- 'master'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: name/app
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
```

View File

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

View File

@ -319,14 +319,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",
@ -352,14 +352,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",
@ -385,14 +385,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",
@ -417,13 +417,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",
@ -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-2665741"
"org.opencontainers.image.version=sha-266574110acf"
],
undefined
],
@ -448,13 +448,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",
@ -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-983315b"
"org.opencontainers.image.version=sha-983315b5e8d4"
],
undefined
],
@ -785,9 +785,6 @@ describe('push', () => {
`type=raw,value=mytag-baseref-{{base_ref}}`,
`type=raw,value=mytag-defbranch,enable={{is_default_branch}}`
],
labels: [
"org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}}"
]
} as Inputs,
{
main: 'mytag-master',
@ -821,40 +818,6 @@ describe('push', () => {
"org.opencontainers.image.version=mytag-master"
],
undefined
],
[
'push22',
'event_push_dev.env',
{
images: ['org/app'],
tags: [
`type=edge,branch=master`,
`type=sha,format=long`,
`type=raw,value=notdefbranch,enable={{is_not_default_branch}}`
],
} as Inputs,
{
main: 'notdefbranch',
partial: [
'sha-860c1904a1ce19322e91ac35af1ab07466440c37'
],
latest: false
} as Version,
[
"org/app:notdefbranch",
"org/app:sha-860c1904a1ce19322e91ac35af1ab07466440c37"
],
[
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.description=This your first repo!",
"org.opencontainers.image.licenses=MIT",
"org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"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=notdefbranch"
],
undefined
]
])('given %p with %p event', tagsLabelsTest);
});
@ -1393,17 +1356,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'
],
[
@ -1433,17 +1396,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'
],
[
@ -1475,17 +1438,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'
],
[
@ -1512,16 +1475,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'
],
[
@ -1532,7 +1495,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
],
@ -1971,69 +1934,6 @@ describe('tag', () => {
"org.opencontainers.image.version=1.1.1"
],
undefined
],
[
'tag34',
'event_tag_p1-v1.0.0.env',
{
images: ['org/app'],
tags: [
`type=semver,pattern={{version}},"match=v(\\d.\\d.\\d)$"`,
]
} as Inputs,
{
main: '1.0.0',
partial: [],
latest: true
} as Version,
[
'org/app:1.0.0',
'org/app:latest'
],
[
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.description=This your first repo!",
"org.opencontainers.image.licenses=MIT",
"org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
"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=1.0.0"
],
undefined
],
[
'push35',
'event_push_master.env',
{
images: ['user/app'],
tags: [
`type=semver,pattern={{version}},value=p1/v1.2.3,"match=v(\\d.\\d.\\d)$"`,
`type=pep440,pattern={{version}},value=p1/v1.2.3,"match=v(\\d.\\d.\\d)$"`,
`type=edge`
],
} as Inputs,
{
main: '1.2.3',
partial: ['edge'],
latest: true
} as Version,
[
'user/app:1.2.3',
'user/app:edge',
'user/app:latest'
],
[
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.description=This your first repo!",
"org.opencontainers.image.licenses=MIT",
"org.opencontainers.image.revision=266574110acf203503badf966df2ea24b5d732d7",
"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=1.2.3"
],
undefined
]
])('given %p with %p event', tagsLabelsTest);
});
@ -2449,14 +2349,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",
@ -2481,14 +2381,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'
],
[
@ -2499,7 +2399,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
],
@ -2582,14 +2482,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'
],
[
@ -2600,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-2665741"
"org.opencontainers.image.version=sha-266574110acf"
],
undefined
],
@ -2654,14 +2554,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'
],
[
@ -2835,14 +2735,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",
@ -2866,14 +2766,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'
],
[
@ -2884,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-3370e22"
"org.opencontainers.image.version=sha-3370e228f220"
]
],
[
@ -2964,14 +2864,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'
],
[
@ -2982,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-3370e22"
"org.opencontainers.image.version=sha-3370e228f220"
]
],
[
@ -3034,14 +2934,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'
],
[
@ -3297,14 +3197,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",
@ -3330,7 +3230,7 @@ describe('schedule', () => {
]
} as Inputs,
{
main: 'sha-860c190',
main: 'sha-860c1904a1ce',
partial: [
'nightly',
'defbranch'
@ -3338,10 +3238,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'
],
@ -3353,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-860c190"
"org.opencontainers.image.version=sha-860c1904a1ce"
],
undefined
],
@ -3936,12 +3836,6 @@ describe('json', () => {
"user/app:custom",
"user/app:tags"
],
"tag-names": [
"dev",
"my",
"custom",
"tags"
],
"labels": {
"foo": "",
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
@ -3980,10 +3874,6 @@ describe('json', () => {
"user/app:dev",
"user/app:my",
],
"tag-names": [
"dev",
"my",
],
"labels": {
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.description": "This your first repo!",
@ -4027,13 +3917,6 @@ describe('json', () => {
"user/app:tags",
"user/app:latest"
],
"tag-names": [
"release1",
"my",
"custom",
"tags",
"latest"
],
"labels": {
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.description": "This your first repo!",
@ -4078,12 +3961,6 @@ describe('json', () => {
"user/app:custom",
"user/app:tags"
],
"tag-names": [
"20200110",
"my",
"custom",
"tags"
],
"labels": {
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.description": "This your first repo!",
@ -4137,15 +4014,6 @@ describe('json', () => {
"ghcr.io/user/app:tags",
"ghcr.io/user/app:latest"
],
"tag-names": [
"1.1.1",
"1.1",
"1",
"my",
"custom",
"tags",
"latest",
],
"labels": {
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.description": "This your first repo!",
@ -4188,11 +4056,6 @@ describe('json', () => {
"ghcr.io/user/app:custom",
"ghcr.io/user/app:tags"
],
"tag-names": [
"my",
"custom",
"tags",
],
"labels": {
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.description": "This your first repo!",
@ -4233,10 +4096,6 @@ describe('json', () => {
"org/app:v1.1.1",
"org/app:latest"
],
"tag-names": [
"v1.1.1",
"latest"
],
"labels": {
"maintainer": "CrazyMax",
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",

View File

@ -32,8 +32,7 @@ describe('transform', () => {
"priority": DefaultPriorities[Type.Semver],
"enable": "true",
"pattern": "{{version}}",
"value": "",
"match": ""
"value": ""
}
},
{
@ -148,8 +147,7 @@ describe('parse', () => {
"priority": DefaultPriorities[Type.Semver],
"enable": "true",
"pattern": "{{version}}",
"value": "",
"match": ""
"value": ""
}
} as Tag,
false
@ -162,8 +160,7 @@ describe('parse', () => {
"priority": "1",
"enable": "true",
"pattern": "{{version}}",
"value": "",
"match": ""
"value": ""
}
} as Tag,
false
@ -176,22 +173,7 @@ describe('parse', () => {
"priority": "1",
"enable": "true",
"pattern": "{{version}}",
"value": "v1.0.0",
"match": ""
}
} as Tag,
false
],
[
`type=semver,priority=1,enable=true,pattern={{version}},value=p1/v1.0.0,"match=v(\\d.\\d.\\d)$"`,
{
type: Type.Semver,
attrs: {
"priority": "1",
"enable": "true",
"pattern": "{{version}}",
"value": "p1/v1.0.0",
"match": "v(\\d.\\d.\\d)$"
"value": "v1.0.0"
}
} as Tag,
false

View File

@ -48,8 +48,6 @@ outputs:
description: 'Generated Docker image version'
tags:
description: 'Generated Docker tags'
tag-names:
description: 'Generated Docker tag names without image base name'
labels:
description: 'Generated Docker labels'
annotations:
@ -61,7 +59,7 @@ outputs:
bake-file-labels:
description: 'Bake definition file with labels'
bake-file-annotations:
description: 'Bake definition file with annotations'
description: 'Bake definiton file with annotations'
bake-file:
description: 'Bake definition file with tags and labels'

300
dist/606.index.js generated vendored
View File

@ -1,300 +0,0 @@
"use strict";
exports.id = 606;
exports.ids = [606];
exports.modules = {
/***/ 606:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ pMap)
/* harmony export */ });
/* unused harmony exports pMapIterable, pMapSkip */
async function pMap(
iterable,
mapper,
{
concurrency = Number.POSITIVE_INFINITY,
stopOnError = true,
signal,
} = {},
) {
return new Promise((resolve_, reject_) => {
if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
}
if (typeof mapper !== 'function') {
throw new TypeError('Mapper function is required');
}
if (!((Number.isSafeInteger(concurrency) && concurrency >= 1) || concurrency === Number.POSITIVE_INFINITY)) {
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
}
const result = [];
const errors = [];
const skippedIndexesMap = new Map();
let isRejected = false;
let isResolved = false;
let isIterableDone = false;
let resolvingCount = 0;
let currentIndex = 0;
const iterator = iterable[Symbol.iterator] === undefined ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
const signalListener = () => {
reject(signal.reason);
};
const cleanup = () => {
signal?.removeEventListener('abort', signalListener);
};
const resolve = value => {
resolve_(value);
cleanup();
};
const reject = reason => {
isRejected = true;
isResolved = true;
reject_(reason);
cleanup();
};
if (signal) {
if (signal.aborted) {
reject(signal.reason);
}
signal.addEventListener('abort', signalListener, {once: true});
}
const next = async () => {
if (isResolved) {
return;
}
const nextItem = await iterator.next();
const index = currentIndex;
currentIndex++;
// Note: `iterator.next()` can be called many times in parallel.
// This can cause multiple calls to this `next()` function to
// receive a `nextItem` with `done === true`.
// The shutdown logic that rejects/resolves must be protected
// so it runs only one time as the `skippedIndex` logic is
// non-idempotent.
if (nextItem.done) {
isIterableDone = true;
if (resolvingCount === 0 && !isResolved) {
if (!stopOnError && errors.length > 0) {
reject(new AggregateError(errors)); // eslint-disable-line unicorn/error-message
return;
}
isResolved = true;
if (skippedIndexesMap.size === 0) {
resolve(result);
return;
}
const pureResult = [];
// Support multiple `pMapSkip`'s.
for (const [index, value] of result.entries()) {
if (skippedIndexesMap.get(index) === pMapSkip) {
continue;
}
pureResult.push(value);
}
resolve(pureResult);
}
return;
}
resolvingCount++;
// Intentionally detached
(async () => {
try {
const element = await nextItem.value;
if (isResolved) {
return;
}
const value = await mapper(element, index);
// Use Map to stage the index of the element.
if (value === pMapSkip) {
skippedIndexesMap.set(index, value);
}
result[index] = value;
resolvingCount--;
await next();
} catch (error) {
if (stopOnError) {
reject(error);
} else {
errors.push(error);
resolvingCount--;
// In that case we can't really continue regardless of `stopOnError` state
// since an iterable is likely to continue throwing after it throws once.
// If we continue calling `next()` indefinitely we will likely end up
// in an infinite loop of failed iteration.
try {
await next();
} catch (error) {
reject(error);
}
}
}
})();
};
// Create the concurrent runners in a detached (non-awaited)
// promise. We need this so we can await the `next()` calls
// to stop creating runners before hitting the concurrency limit
// if the iterable has already been marked as done.
// NOTE: We *must* do this for async iterators otherwise we'll spin up
// infinite `next()` calls by default and never start the event loop.
(async () => {
for (let index = 0; index < concurrency; index++) {
try {
// eslint-disable-next-line no-await-in-loop
await next();
} catch (error) {
reject(error);
break;
}
if (isIterableDone || isRejected) {
break;
}
}
})();
});
}
function pMapIterable(
iterable,
mapper,
{
concurrency = Number.POSITIVE_INFINITY,
backpressure = concurrency,
} = {},
) {
if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
}
if (typeof mapper !== 'function') {
throw new TypeError('Mapper function is required');
}
if (!((Number.isSafeInteger(concurrency) && concurrency >= 1) || concurrency === Number.POSITIVE_INFINITY)) {
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
}
if (!((Number.isSafeInteger(backpressure) && backpressure >= concurrency) || backpressure === Number.POSITIVE_INFINITY)) {
throw new TypeError(`Expected \`backpressure\` to be an integer from \`concurrency\` (${concurrency}) and up or \`Infinity\`, got \`${backpressure}\` (${typeof backpressure})`);
}
return {
async * [Symbol.asyncIterator]() {
const iterator = iterable[Symbol.asyncIterator] === undefined ? iterable[Symbol.iterator]() : iterable[Symbol.asyncIterator]();
const promises = [];
let runningMappersCount = 0;
let isDone = false;
let index = 0;
function trySpawn() {
if (isDone || !(runningMappersCount < concurrency && promises.length < backpressure)) {
return;
}
const promise = (async () => {
const {done, value} = await iterator.next();
if (done) {
return {done: true};
}
runningMappersCount++;
// Spawn if still below concurrency and backpressure limit
trySpawn();
try {
const returnValue = await mapper(await value, index++);
runningMappersCount--;
if (returnValue === pMapSkip) {
const index = promises.indexOf(promise);
if (index > 0) {
promises.splice(index, 1);
}
}
// Spawn if still below backpressure limit and just dropped below concurrency limit
trySpawn();
return {done: false, value: returnValue};
} catch (error) {
isDone = true;
return {error};
}
})();
promises.push(promise);
}
trySpawn();
while (promises.length > 0) {
const {error, done, value} = await promises[0]; // eslint-disable-line no-await-in-loop
promises.shift();
if (error) {
throw error;
}
if (done) {
return;
}
// Spawn if just dropped below backpressure limit and below the concurrency limit
trySpawn();
if (value === pMapSkip) {
continue;
}
yield value;
}
},
};
}
const pMapSkip = Symbol('skip');
/***/ })
};
;
//# sourceMappingURL=606.index.js.map

1
dist/606.index.js.map generated vendored

File diff suppressed because one or more lines are too long

96
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

4051
dist/licenses.txt generated vendored

File diff suppressed because it is too large Load Diff

2
dist/sourcemap-register.js generated vendored

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,3 @@
target "_common" {
args = {
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
}
}
group "default" {
targets = ["build"]
}
@ -17,49 +11,42 @@ group "validate" {
}
target "build" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
target = "build-update"
output = ["."]
}
target "build-validate" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
target = "build-validate"
output = ["type=cacheonly"]
}
target "format" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
target = "format-update"
output = ["."]
}
target "lint" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
target = "lint"
output = ["type=cacheonly"]
}
target "vendor" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
target = "vendor-update"
output = ["."]
}
target "vendor-validate" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
target = "vendor-validate"
output = ["type=cacheonly"]
}
target "test" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
target = "test-coverage"
output = ["./coverage"]

View File

@ -25,33 +25,34 @@
],
"author": "Docker Inc.",
"license": "Apache-2.0",
"packageManager": "yarn@4.9.2",
"packageManager": "yarn@3.6.3",
"dependencies": {
"@actions/core": "^1.11.1",
"@actions/github": "^6.0.1",
"@docker/actions-toolkit": "^0.68.0",
"@actions/github": "^6.0.0",
"@docker/actions-toolkit": "^0.44.0",
"@renovate/pep440": "^1.0.0",
"csv-parse": "^6.1.0",
"csv-parse": "^5.5.6",
"handlebars": "^4.7.8",
"moment": "^2.30.1",
"moment-timezone": "^0.6.0",
"semver": "^7.7.3"
"moment-timezone": "^0.5.46",
"semver": "^7.6.3"
},
"devDependencies": {
"@types/node": "^20.19.9",
"@types/semver": "^7.7.1",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@vercel/ncc": "^0.38.3",
"dotenv": "^16.6.1",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.2",
"eslint-plugin-jest": "^28.14.0",
"eslint-plugin-prettier": "^5.5.4",
"@types/csv-parse": "^1.2.2",
"@types/node": "^20.12.12",
"@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^7.9.0",
"@typescript-eslint/parser": "^7.9.0",
"@vercel/ncc": "^0.38.1",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^28.5.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"prettier": "^3.6.2",
"ts-jest": "^29.4.1",
"prettier": "^3.2.5",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.9.2"
"typescript": "^5.4.5"
}
}

View File

@ -119,18 +119,11 @@ async function getCommitDateFromWorkflow(sha: string, toolkit: Toolkit): Promise
}
// fallback to github api for commit date
try {
const commit = await toolkit.github.octokit.rest.repos.getCommit({
const commit = await toolkit.github.octokit.request('GET /repos/{owner}/{repo}/commits/{commit_sha}', {
commit_sha: sha,
owner: GitHub.context.repo.owner,
repo: GitHub.context.repo.repo,
ref: sha
repo: GitHub.context.repo.repo
});
if (commit.data.commit.committer?.date) {
return new Date(commit.data.commit.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();
}
return new Date(commit.data.committer.date);
}

View File

@ -2,7 +2,6 @@ import * as fs from 'fs';
import * as core from '@actions/core';
import * as actionsToolkit from '@docker/actions-toolkit';
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
import {Util} from '@docker/actions-toolkit/lib/util';
import {getContext, getInputs, Inputs} from './context';
import {Meta, Version} from './meta';
@ -14,7 +13,6 @@ actionsToolkit.run(
const toolkit = new Toolkit({githubToken: inputs.githubToken});
const context = await getContext(inputs.context, toolkit);
const repo = await toolkit.github.repoData();
const setOutput = outputEnvEnabled() ? setOutputAndEnv : core.setOutput;
await core.group(`Context info`, async () => {
core.info(`eventName: ${context.eventName}`);
@ -47,7 +45,7 @@ actionsToolkit.run(
setOutput('version', version.main || '');
// Docker tags
const tags = meta.getTags();
const tags: Array<string> = meta.getTags();
if (tags.length == 0) {
core.warning('No Docker tag has been generated. Check tags input.');
} else {
@ -58,7 +56,6 @@ actionsToolkit.run(
});
}
setOutput('tags', tags.join(inputs.sepTags));
setOutput('tag-names', meta.getTags(true).join(inputs.sepTags));
// Docker labels
const labels: Array<string> = meta.getLabels();
@ -108,14 +105,7 @@ actionsToolkit.run(
}
);
function setOutputAndEnv(name: string, value: string) {
function setOutput(name: string, value: string) {
core.setOutput(name, value);
core.exportVariable(`DOCKER_METADATA_OUTPUT_${name.replace(/\W/g, '_').toUpperCase()}`, value);
}
function outputEnvEnabled(): boolean {
if (process.env.DOCKER_METADATA_SET_OUTPUT_ENV) {
return Util.parseBool(process.env.DOCKER_METADATA_SET_OUTPUT_ENV);
}
return true;
}

View File

@ -13,7 +13,7 @@ import * as icl from './image';
import * as tcl from './tag';
import * as fcl from './flavor';
const defaultShortShaLength = 7;
const defaultShortShaLength = 12;
export interface Version {
main: string | undefined;
@ -161,20 +161,8 @@ export class Meta {
if (tag.attrs['value'].length > 0) {
vraw = this.setGlobalExp(tag.attrs['value']);
} else {
vraw = this.context.ref.replace(/^refs\/tags\//g, '');
vraw = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
}
if (tag.attrs['match'].length > 0) {
const tmatch = vraw.match(tag.attrs['match']);
if (!tmatch) {
core.warning(`${tag.attrs['match']} does not match ${vraw}.`);
} else {
vraw = tmatch[1];
}
}
vraw = vraw.replace(/\//g, '-');
if (!semver.valid(vraw)) {
core.warning(`${vraw} is not a valid semver. More info: https://semver.org/`);
return version;
@ -207,20 +195,8 @@ export class Meta {
if (tag.attrs['value'].length > 0) {
vraw = this.setGlobalExp(tag.attrs['value']);
} else {
vraw = this.context.ref.replace(/^refs\/tags\//g, '');
vraw = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
}
if (tag.attrs['match'].length > 0) {
const tmatch = vraw.match(tag.attrs['match']);
if (!tmatch) {
core.warning(`${tag.attrs['match']} does not match ${vraw}.`);
} else {
vraw = tmatch[1];
}
}
vraw = vraw.replace(/\//g, '-');
if (!pep440.valid(vraw)) {
core.warning(`${vraw} does not conform to PEP 440. More info: https://www.python.org/dev/peps/pep-0440`);
return version;
@ -396,7 +372,7 @@ export class Meta {
return val;
}
private setGlobalExp(val: string): string {
private setGlobalExp(val): string {
const context = this.context;
const currentDate = this.date;
const commitDate = this.context.commitDate;
@ -463,9 +439,6 @@ export class Meta {
}
return 'false';
},
is_not_default_branch: function () {
return this.is_default_branch() === 'false' ? 'true' : 'false';
},
date: function (format, options) {
const m = moment(currentDate);
let tz = 'UTC';
@ -494,30 +467,14 @@ export class Meta {
return images;
}
public getTags(namesOnly?: boolean): Array<string> {
public getTags(): Array<string> {
if (!this.version.main) {
return [];
}
if (namesOnly) {
return this.generateTags(this.version.main);
}
const generateTags = (imageName: string, version: string): Array<string> => {
const tags: Array<string> = [];
const images = this.getImageNames();
if (images.length > 0) {
for (const imageName of images) {
tags.push(...this.generateTags(this.version.main, imageName));
}
} else {
tags.push(...this.generateTags(this.version.main));
}
return tags;
}
private generateTags(version: string, imageName?: string): Array<string> {
const tags: Array<string> = [];
const prefix = imageName ? `${imageName}:` : '';
const prefix = imageName !== '' ? `${imageName}:` : '';
tags.push(`${prefix}${version}`);
for (const partial of this.version.partial) {
tags.push(`${prefix}${partial}`);
@ -527,6 +484,18 @@ export class Meta {
tags.push(`${prefix}${Meta.sanitizeTag(latestTag)}`);
}
return tags;
};
const tags: Array<string> = [];
const images = this.getImageNames();
if (images.length > 0) {
for (const imageName of images) {
tags.push(...generateTags(imageName, this.version.main));
}
} else {
tags.push(...generateTags('', this.version.main));
}
return tags;
}
public getLabels(): Array<string> {
@ -548,9 +517,7 @@ export class Meta {
`org.opencontainers.image.revision=${this.context.sha || ''}`,
`org.opencontainers.image.licenses=${this.repo.license?.spdx_id || ''}`
];
extra.forEach(label => {
res.push(this.setGlobalExp(label));
});
res.push(...extra);
return Array.from(
new Map<string, string>(
@ -572,7 +539,6 @@ export class Meta {
}
return {
tags: this.getTags(),
'tag-names': this.getTags(true),
labels: this.getLabels().reduce((res, label) => {
const matches = label.match(/([^=]*)=(.*)/);
if (!matches) {

View File

@ -104,10 +104,10 @@ export function Parse(s: string): Tag {
const value = parts[1];
switch (key) {
case 'type': {
if (!Object.values(Type).includes(value as Type)) {
if (!Object.values(Type).includes(value)) {
throw new Error(`Unknown tag type attribute: ${value}`);
}
tag.type = value as Type;
tag.type = value;
break;
}
default: {
@ -137,9 +137,6 @@ export function Parse(s: string): Tag {
if (!Object.prototype.hasOwnProperty.call(tag.attrs, 'value')) {
tag.attrs['value'] = '';
}
if (!Object.prototype.hasOwnProperty.call(tag.attrs, 'match')) {
tag.attrs['match'] = '';
}
break;
}
case Type.Match: {

5140
yarn.lock

File diff suppressed because it is too large Load Diff