Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: docker/metadata-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.7.0
Choose a base ref
...
head repository: docker/metadata-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.8.0
Choose a head ref

Commits on Apr 12, 2022

  1. Bump semver from 7.3.5 to 7.3.7

    Bumps [semver](https://github.com/npm/node-semver) from 7.3.5 to 7.3.7.
    - [Release notes](https://github.com/npm/node-semver/releases)
    - [Changelog](https://github.com/npm/node-semver/blob/main/CHANGELOG.md)
    - [Commits](npm/node-semver@v7.3.5...v7.3.7)
    
    ---
    updated-dependencies:
    - dependency-name: semver
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 12, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    sfackler Steven Fackler
    Copy the full SHA
    d0dafec View commit details

Commits on Apr 19, 2022

  1. dev: update fixtures

    Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
    crazy-max committed Apr 19, 2022
    Copy the full SHA
    5f62bc0 View commit details

Commits on Apr 20, 2022

  1. Merge pull request #190 from crazy-max/dev-test-fixtures

    dev: update fixtures
    crazy-max authored Apr 20, 2022
    Copy the full SHA
    0950af0 View commit details

Commits on Apr 25, 2022

  1. Update generated content

    Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
    crazy-max committed Apr 25, 2022
    Copy the full SHA
    ba82704 View commit details
  2. Merge pull request #185 from docker/dependabot/npm_and_yarn/semver-7.3.7

    Bump semver from 7.3.5 to 7.3.7
    crazy-max authored Apr 25, 2022
    Copy the full SHA
    7fa3798 View commit details
  3. Bump moment from 2.29.2 to 2.29.3

    Bumps [moment](https://github.com/moment/moment) from 2.29.2 to 2.29.3.
    - [Release notes](https://github.com/moment/moment/releases)
    - [Changelog](https://github.com/moment/moment/blob/2.29.3/CHANGELOG.md)
    - [Commits](moment/moment@2.29.2...2.29.3)
    
    ---
    updated-dependencies:
    - dependency-name: moment
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 25, 2022
    Copy the full SHA
    e29c9db View commit details
  4. Update generated content

    Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
    crazy-max committed Apr 25, 2022
    Copy the full SHA
    476e707 View commit details
  5. Merge pull request #187 from docker/dependabot/npm_and_yarn/moment-2.…

    …29.3
    
    Bump moment from 2.29.2 to 2.29.3
    crazy-max authored Apr 25, 2022
    Copy the full SHA
    a3ea951 View commit details
  6. Bump csv-parse from 4.16.3 to 5.0.4

    Bumps [csv-parse](https://github.com/adaltas/node-csv/tree/HEAD/packages/csv-parse) from 4.16.3 to 5.0.4.
    - [Release notes](https://github.com/adaltas/node-csv/releases)
    - [Changelog](https://github.com/adaltas/node-csv/blob/master/packages/csv-parse/CHANGELOG.md)
    - [Commits](https://github.com/adaltas/node-csv/commits/csv-parse@5.0.4/packages/csv-parse)
    
    ---
    updated-dependencies:
    - dependency-name: csv-parse
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Apr 25, 2022
    Copy the full SHA
    2a96a96 View commit details
  7. Fix csv-parse implementation since major update

    Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
    crazy-max committed Apr 25, 2022
    Copy the full SHA
    b7ad32e View commit details
  8. Update generated content

    Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
    crazy-max committed Apr 25, 2022
    Copy the full SHA
    4b640ab View commit details
  9. Merge pull request #195 from docker/dependabot/npm_and_yarn/csv-parse…

    …-5.0.4
    
    Bump csv-parse from 4.16.3 to 5.0.4
    crazy-max authored Apr 25, 2022
    Copy the full SHA
    5351305 View commit details
  10. is_default_branch global expression

    Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
    crazy-max committed Apr 25, 2022
    Copy the full SHA
    e1a45f6 View commit details
  11. log webhook payload if action step debug enabled

    Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
    crazy-max committed Apr 25, 2022
    Copy the full SHA
    89bf6c0 View commit details
  12. fix undefined base_ref for some events

    Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
    crazy-max committed Apr 25, 2022
    Copy the full SHA
    7d7a22a View commit details
  13. ci: add global expressions job

    Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
    crazy-max committed Apr 25, 2022
    Copy the full SHA
    c2905fb View commit details
  14. Merge pull request #192 from crazy-max/default-branch

    is_default_branch global expression
    crazy-max authored Apr 25, 2022
    Copy the full SHA
    0978a06 View commit details

Commits on Apr 26, 2022

  1. remove support of default branch global exp for push tag events

    Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
    crazy-max committed Apr 26, 2022
    Copy the full SHA
    aca951f View commit details
  2. Merge pull request #197 from crazy-max/rm-baseref-def-branch

    remove support of default branch global exp for push tag events
    crazy-max authored Apr 26, 2022
    Copy the full SHA
    72fe50e View commit details
  3. don't handle default branch global exp for pr events

    Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
    crazy-max committed Apr 26, 2022
    Copy the full SHA
    0a72be4 View commit details
  4. Merge pull request #198 from crazy-max/refactor-default-banch

    don't handle default branch global exp for pr events
    crazy-max authored Apr 26, 2022
    Copy the full SHA
    be6d2cc View commit details

Commits on Apr 27, 2022

  1. attribute to enable/disable images

    Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
    crazy-max committed Apr 27, 2022
    Copy the full SHA
    a5680a6 View commit details

Commits on Apr 28, 2022

  1. backward compatibility with old images format

    Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
    crazy-max committed Apr 28, 2022
    Copy the full SHA
    2f4dd14 View commit details
  2. Merge pull request #193 from crazy-max/images-opts

    attribute to enable/disable images
    crazy-max authored Apr 28, 2022
    Copy the full SHA
    b2391d3 View commit details
Showing with 3,716 additions and 1,233 deletions.
  1. +38 −1 .github/workflows/ci.yml
  2. +125 −36 README.md
  3. +30 −0 __tests__/fixtures/event_create_branch.env
  4. +145 −0 __tests__/fixtures/event_create_branch.json
  5. +30 −0 __tests__/fixtures/event_create_tag.env
  6. +145 −0 __tests__/fixtures/event_create_tag.json
  7. +30 −0 __tests__/fixtures/event_discussion_created.env
  8. +205 −0 __tests__/fixtures/event_discussion_created.json
  9. +30 −0 __tests__/fixtures/event_discussion_pinned.env
  10. +205 −0 __tests__/fixtures/event_discussion_pinned.json
  11. +30 −0 __tests__/fixtures/event_issue_opened.env
  12. +200 −0 __tests__/fixtures/event_issue_opened.json
  13. +19 −12 __tests__/fixtures/event_pull_request.env
  14. +184 −168 __tests__/fixtures/event_pull_request.json
  15. +16 −11 __tests__/fixtures/event_pull_request_target.env
  16. +247 −219 __tests__/fixtures/event_pull_request_target.json
  17. +0 −23 __tests__/fixtures/event_push.env
  18. +0 −181 __tests__/fixtures/event_push.json
  19. +0 −23 __tests__/fixtures/event_push_defbranch.env
  20. +30 −0 __tests__/fixtures/event_push_dev.env
  21. +195 −0 __tests__/fixtures/event_push_dev.json
  22. +19 −12 __tests__/fixtures/event_push_invalidchars.env
  23. +195 −0 __tests__/fixtures/event_push_invalidchars.json
  24. +30 −0 __tests__/fixtures/event_push_master.env
  25. +195 −0 __tests__/fixtures/event_push_master.json
  26. +0 −23 __tests__/fixtures/event_release.env
  27. +30 −0 __tests__/fixtures/event_release_created.env
  28. +80 −0 __tests__/fixtures/event_release_created.json
  29. +18 −11 __tests__/fixtures/event_schedule.env
  30. +3 −0 __tests__/fixtures/event_schedule.json
  31. +18 −11 __tests__/fixtures/event_tag_1.0dev4.env
  32. +18 −11 __tests__/fixtures/event_tag_1.1beta2.env
  33. +18 −11 __tests__/fixtures/event_tag_1.2.3rc2.env
  34. +18 −11 __tests__/fixtures/event_tag_1.2.env
  35. +18 −11 __tests__/fixtures/event_tag_1.2post1.env
  36. +18 −11 __tests__/fixtures/event_tag_20200110-RC2.env
  37. +18 −11 __tests__/fixtures/event_tag_p1-v1.0.0.env
  38. +18 −11 __tests__/fixtures/event_tag_release1.env
  39. +18 −11 __tests__/fixtures/event_tag_sometag.env
  40. +17 −10 __tests__/fixtures/event_tag_v1.1.1.env
  41. +88 −74 __tests__/fixtures/event_tag_v1.1.1.json
  42. +18 −11 __tests__/fixtures/event_tag_v1.2.3rc2.env
  43. +18 −11 __tests__/fixtures/event_tag_v2.0.8-beta.67.env
  44. +18 −11 __tests__/fixtures/event_workflow_dispatch.env
  45. +145 −0 __tests__/fixtures/event_workflow_dispatch.json
  46. +30 −0 __tests__/fixtures/event_workflow_dispatch_dev.env
  47. +145 −0 __tests__/fixtures/event_workflow_dispatch_dev.json
  48. +101 −0 __tests__/image.test.ts
  49. +309 −229 __tests__/meta.test.ts
  50. +0 −5 __tests__/tag.test.ts
  51. +11 −11 dist/index.js
  52. +1 −1 dist/index.js.map
  53. +3 −0 jest.config.ts
  54. +3 −3 package.json
  55. +12 −10 src/context.ts
  56. +3 −3 src/flavor.ts
  57. +1 −3 src/github.ts
  58. +86 −0 src/image.ts
  59. +6 −0 src/main.ts
  60. +53 −12 src/meta.ts
  61. +3 −6 src/tag.ts
  62. +9 −14 yarn.lock
39 changes: 38 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -146,6 +146,21 @@ jobs:
prefix=foo-
suffix=-bar
images:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Docker meta
uses: ./
with:
images: |
name=${{ env.DOCKER_IMAGE }}
name=ghcr.io/name/app,enable=${{ github.event_name == 'pull_request' }}
name=ghcr.io/name/release,enable=${{ startsWith(github.ref, 'refs/tags/') }}
labels:
runs-on: ubuntu-latest
steps:
@@ -165,6 +180,27 @@ jobs:
org.opencontainers.image.description=this is a "good" example
org.opencontainers.image.vendor=MyCompany
global-exps:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Docker meta
uses: ./
with:
images: |
${{ env.DOCKER_IMAGE }}
ghcr.io/name/app
tags: |
type=sha
type=raw,value=gexp-branch-{{branch}}
type=raw,value=gexp-date-{{date 'YYYYMMDD'}}
type=raw,value=gexp-tag-{{tag}}
type=raw,value=gexp-baseref-{{base_ref}}
type=raw,value=gexp-defbranch,enable={{is_default_branch}}
json:
runs-on: ubuntu-latest
steps:
@@ -205,7 +241,8 @@ jobs:
id: docker_meta
uses: ./
with:
images: ${{ env.DOCKER_IMAGE }}
images: |
${{ env.DOCKER_IMAGE }}
tags: |
type=schedule
type=ref,event=branch
161 changes: 125 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ ___
* [Customizing](#customizing)
* [inputs](#inputs)
* [outputs](#outputs)
* [`images` input](#images-input)
* [`flavor` input](#flavor-input)
* [`tags` input](#tags-input)
* [`type=schedule`](#typeschedule)
@@ -32,6 +33,12 @@ ___
* [Notes](#notes)
* [Latest tag](#latest-tag)
* [Global expressions](#global-expressions)
* [`{{branch}}`](#branch)
* [`{{tag}}`](#tag)
* [`{{sha}}`](#sha)
* [`{{base_ref}}`](#base_ref)
* [`{{is_default_branch}}`](#is_default_branch)
* [`{{date '<format>'}}`](#date-format)
* [Major version zero](#major-version-zero)
* [JSON output object](#json-output-object)
* [Overwrite labels](#overwrite-labels)
@@ -119,7 +126,8 @@ jobs:
id: meta
uses: docker/metadata-action@v3
with:
images: name/app
images: |
name/app
tags: |
type=ref,event=branch
type=ref,event=pr
@@ -196,7 +204,8 @@ jobs:
id: meta
uses: docker/metadata-action@v3
with:
images: name/app
images: |
name/app
tags: |
type=ref,event=branch
type=ref,event=pr
@@ -232,7 +241,7 @@ Content of `${{ steps.meta.outputs.bake-file }}` file will look like this with `
"org.opencontainers.image.source": "https://github.com/octocat/Hello-World",
"org.opencontainers.image.version": "1.2.3",
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.revision": "860c1904a1ce19322e91ac35af1ab07466440c37",
"org.opencontainers.image.licenses": "MIT"
},
"args": {
@@ -258,33 +267,51 @@ Following inputs can be used as `step.with` keys
> org.opencontainers.image.vendor=MyCompany
> ```

> `CSV` type is a comma-delimited string
> ```yaml
> images: name/app,ghcr.io/name/app
> ```

| Name | Type | Description |
|---------------------|----------|------------------------------------|
| `images` | List/CSV | List of Docker images to use as base name for tags |
| `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 |
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
| `bake-target` | String | Bake target name (default `docker-metadata-action`) |
| Name | Type | Description |
|---------------------|--------|----------------------------------------------------------|
| `images` | List | List of Docker images to use as base name for tags |
| `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 |
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
| `bake-target` | String | Bake target name (default `docker-metadata-action`) |

### outputs

Following outputs are available

| Name | Type | Description |
|---------------|---------|---------------------------------------|
| `version` | String | Docker image version |
| `tags` | String | Docker tags |
| `labels` | String | Docker labels |
| `json` | String | JSON output of tags and labels |
| Name | Type | Description |
|---------------|---------|-------------------------------------------------------------------------------|
| `version` | String | Docker image version |
| `tags` | String | Docker tags |
| `labels` | String | Docker labels |
| `json` | String | JSON output of tags and labels |
| `bake-file` | File | [Bake definition file](https://github.com/docker/buildx#file-definition) path |

## `images` input

`images` defines a list of Docker images to use as base name for [`tags`](#tags-input):

```yaml
images: |
name/foo
ghcr.io/name/bar
# or
name=name/foo
name=ghcr.io/name/bar
```

Extended attributes and default values:

```yaml
images: |
name=,enable=true
```

* `name=<string>` image base name
* `enable=<true|false>` enable this entry (default `true`)

## `flavor` input

`flavor` defines a global behavior for [`tags`](#tags-input):
@@ -605,26 +632,28 @@ tags: |
* [`type=semver,pattern=...`](#typesemver)
* [`type=match,pattern=...`](#typematch)

For conditionally tagging with latest for a specific branch name, e.g. if your default branch name
is not `master`, use `type=raw` with a boolean expression:
For conditionally tagging with latest for a specific branch name, e.g. if your
default branch name is not `master`, use `type=raw` with a boolean expression:

```yaml
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
# set latest tag for master branch
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
```

### Global expressions
You can also use the [`{{is_default_branch}}` global expression](#is_default_branch)
to conditionally tag with latest for the default branch:

The following [Handlebars' template](https://handlebarsjs.com/guide/) expressions for `prefix`, `suffix` and `value`
attributes are available:
```yaml
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
```

| Expression | Output |
|--------------------------|----------------------|
| `{{branch}}` | `master` |
| `{{tag}}` | `v1.2.3` |
| `{{sha}}` | `90dd603` |
| `{{base_ref}}` | `master` |
| `{{date 'YYYYMMDD'}}` | `20210326` |
### Global expressions

The following [Handlebars' template](https://handlebarsjs.com/guide/) expressions
for `prefix`, `suffix`, `value` and `enable` attributes are available:

```yaml
tags: |
@@ -634,6 +663,66 @@ tags: |
type=raw,value=mytag-{{branch}}-{{sha}}
```

#### `{{branch}}`

Returns the branch name that triggered the workflow run. Will be empty if not
a branch reference:

| Event | Ref | Output |
|-----------------|-------------------------------|---------------------|
| `pull_request` | `refs/pull/2/merge` | |
| `push` | `refs/heads/master` | `master` |
| `push` | `refs/heads/my/branch` | `my-branch` |
| `push tag` | `refs/tags/v1.2.3` | |

#### `{{tag}}`

Returns the tag name that triggered the workflow run. Will be empty if not a
tag reference:

| Event | Ref | Output |
|-----------------|-------------------------------|--------------------|
| `pull_request` | `refs/pull/2/merge` | |
| `push` | `refs/heads/master` | |
| `push` | `refs/heads/my/branch` | |
| `push tag` | `refs/tags/v1.2.3` | `v1.2.3` |

#### `{{sha}}`

Returns the short commit SHA that triggered the workflow run (e.g., `90dd603`).

#### `{{base_ref}}`

Returns the base ref or target branch of the pull request that triggered the
workflow run. Will be empty for a branch reference:

| Event | Ref | Output |
|----------------|-------------------------------|--------------------|
| `pull_request` | `refs/pull/2/merge` | `master` |
| `push` | `refs/heads/master` | |
| `push` | `refs/heads/my/branch` | |
| `push tag`* | `refs/tags/v1.2.3` | `master` |

> *`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).
> We keep it for backward compatibility, but it's **not recommended relying on it**.
> More context in [#192](https://github.com/docker/metadata-action/pull/192#discussion_r854673012).

#### `{{is_default_branch}}`

Returns `true` if the branch that triggered the workflow run is the default
one, otherwise `false`.

#### `{{date '<format>'}}`

Returns the current date rendered by its [moment format](https://momentjs.com/docs/#/displaying/format/).

| Expression | Output example |
|--------------------------------------------|-----------------------------------------|
| `{{date 'YYYYMMDD'}}` | `20200110` |
| `{{date 'dddd, MMMM Do YYYY, h:mm:ss a'}}` | `Friday, January 10th 2020, 3:25:50 pm` |

### Major version zero

Major version zero (`0.y.z`) is for initial development and **may** change at any time. This means the public API
30 changes: 30 additions & 0 deletions __tests__/fixtures/event_create_branch.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
GITHUB_ACTION=__crazy-max_ghaction-dump-context
GITHUB_ACTIONS=true
GITHUB_ACTION_PATH=/home/runner/work/_actions/crazy-max/ghaction-dump-context/v1
GITHUB_ACTION_REF=
GITHUB_ACTION_REPOSITORY=
GITHUB_ACTOR=crazy-max
GITHUB_API_URL=https://api.github.com
GITHUB_BASE_REF=
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_49ba9b4e-1733-447c-b700-1cea19f95b82
GITHUB_EVENT_NAME=create
GITHUB_EVENT_PATH=./__tests__/fixtures/event_create_branch.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=
GITHUB_JOB=test
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_49ba9b4e-1733-447c-b700-1cea19f95b82
GITHUB_REF=refs/heads/dev
GITHUB_REF_NAME=dev
GITHUB_REF_PROTECTED=false
GITHUB_REF_TYPE=branch
GITHUB_REPOSITORY=docker/test-docker-action
GITHUB_REPOSITORY_OWNER=docker
GITHUB_RETENTION_DAYS=90
GITHUB_RUN_ATTEMPT=1
GITHUB_RUN_ID=2188731929
GITHUB_RUN_NUMBER=14
GITHUB_SERVER_URL=https://github.com
GITHUB_SHA=5f3331d7f7044c18ca9f12c77d961c4d7cf3276a
GITHUB_STEP_SUMMARY=/home/runner/work/_temp/_runner_file_commands/step_summary_49ba9b4e-1733-447c-b700-1cea19f95b82
GITHUB_WORKFLOW=metadata
GITHUB_WORKSPACE=/home/runner/work/test-docker-action/test-docker-action
Loading