Giter Club home page Giter Club logo

metadata-action's Introduction

GitHub release GitHub marketplace CI workflow Test workflow Codecov

About

GitHub Action to extract metadata from Git reference and GitHub events. This action is particularly useful if used with Docker Build Push action to tag and label Docker images.

Screenshot


Usage

Basic

name: ci

on:
  workflow_dispatch:
  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 }}
Event Ref Docker Tags
pull_request refs/pull/2/merge pr-2
push refs/heads/master master
push refs/heads/releases/v1 releases-v1
push tag refs/tags/v1.2.3 v1.2.3, latest
push tag refs/tags/v2.0.8-beta.67 v2.0.8-beta.67, latest
workflow_dispatch refs/heads/master master

Semver

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 }}
Event Ref Docker Tags
pull_request refs/pull/2/merge pr-2
push refs/heads/master master
push refs/heads/releases/v1 releases-v1
push tag refs/tags/v1.2.3 1.2.3, 1.2, latest
push tag refs/tags/v2.0.8-beta.67 2.0.8-beta.67

Bake definition

This action also handles a bake definition file that can be used with the Docker Bake action. You just have to declare an empty target named docker-metadata-action and inherit from it.

// docker-bake.hcl
target "docker-metadata-action" {}

target "build" {
  inherits = ["docker-metadata-action"]
  context = "./"
  dockerfile = "Dockerfile"
  platforms = [
    "linux/amd64",
    "linux/arm/v6",
    "linux/arm/v7",
    "linux/arm64",
    "linux/386"
  ]
}
name: ci

on:
  push:
    branches:
      - 'master'
    tags:
      - 'v*'

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}}
            type=sha
      -
        name: Build
        uses: docker/bake-action@v4
        with:
          files: |
            ./docker-bake.hcl
            ${{ steps.meta.outputs.bake-file }}
          targets: build

Content of ${{ steps.meta.outputs.bake-file }} file, combining tags and labels, will look like this with refs/tags/v1.2.3 ref:

{
  "target": {
    "docker-metadata-action": {
      "tags": [
        "name/app:1.2.3",
        "name/app:1.2",
        "name/app:sha-90dd603",
        "name/app:latest"
      ],
      "labels": {
        "org.opencontainers.image.title": "Hello-World",
        "org.opencontainers.image.description": "This your first repo!",
        "org.opencontainers.image.url": "https://github.com/octocat/Hello-World",
        "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": "860c1904a1ce19322e91ac35af1ab07466440c37",
        "org.opencontainers.image.licenses": "MIT"
      },
      "args": {
        "DOCKER_META_IMAGES": "name/app",
        "DOCKER_META_VERSION": "1.2.3"
      }
    }
  }
}

You can also use the bake-file-tags and bake-file-labels outputs if you just want to use tags and/or labels respectively. The following example is similar to the previous one:

      -
        name: Build
        uses: docker/bake-action@v4
        with:
          files: |
            ./docker-bake.hcl
            ${{ steps.meta.outputs.bake-file-tags }}
            ${{ steps.meta.outputs.bake-file-labels }}
          targets: build

If you're building a remote Bake definition using a Git context, you must specify the location of the metadata-only bake file using a cwd:// prefix:

      -
        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

Customizing

inputs

The following inputs can be used as step.with keys:

List type is a newline-delimited string

labels: |
  org.opencontainers.image.title=MyCustomTitle
  org.opencontainers.image.description=Another description
  org.opencontainers.image.vendor=MyCompany
Name Type Description
context String Where to get context data. Allowed options are: workflow (default), git.
images List List of Docker images to use as base name for tags
tags List List of tags as key-value pair attributes
flavor List Flavor to apply
labels List List of custom labels
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)
bake-target String Bake target name (default docker-metadata-action)

outputs

The following outputs are available:

Name Type Description
version String Docker image version
tags String Docker tags
labels String Docker labels
annotations String Annotations
json String JSON output of tags and labels
bake-file-tags File Bake file definition path with tags
bake-file-labels File Bake file definition path with labels
bake-file-annotations File Bake file definition path with annotations

Alternatively, each output is also exported as an environment variable:

  • DOCKER_METADATA_OUTPUT_VERSION
  • DOCKER_METADATA_OUTPUT_TAGS
  • DOCKER_METADATA_OUTPUT_LABELS
  • DOCKER_METADATA_OUTPUT_ANNOTATIONS
  • DOCKER_METADATA_OUTPUT_JSON
  • DOCKER_METADATA_OUTPUT_BAKE_FILE_TAGS
  • DOCKER_METADATA_OUTPUT_BAKE_FILE_LABELS
  • DOCKER_METADATA_OUTPUT_BAKE_FILE_ANNOTATIONS

So it can be used with our Docker Build Push action:

- uses: docker/build-push-action@v5
  with:
    build-args: |
      DOCKER_METADATA_OUTPUT_JSON

environment variables

Name Type Description
DOCKER_METADATA_PR_HEAD_SHA Bool If true, set associated head SHA instead of commit SHA that triggered the workflow on pull request event
DOCKER_METADATA_ANNOTATIONS_LEVELS String Comma separated list of annotations levels to set for annotations output separated (default manifest)

context input

context defines where to get context metadata:

# default
context: workflow
# or
context: git

images input

images defines a list of Docker images to use as base name for tags:

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

Extended attributes and default values:

images: |
  name=,enable=true
  • name=<string> image base name
  • enable=<true|false> enable this entry (default true)

If images is empty, tags will be generated without base name.

flavor input

flavor defines a global behavior for tags:

flavor: |
  latest=auto
  prefix=
  suffix=
  • latest=<auto|true|false>: Handle latest tag (default auto)
  • prefix=<string>,onlatest=<true|false>: A global prefix for each generated tag and optionally for latest
  • suffix=<string>,onlatest=<true|false>: A global suffix for each generated tag and optionally for latest

tags input

tags is the core input of this action as everything related to it will reflect the output metadata. This one is in the form of a key-value pair list in CSV format to remove limitations intrinsically linked to GitHub Actions (only string format is handled in the input fields). Here is an example:

tags: |
  type=schedule
  type=semver,pattern={{version}}
  type=semver,pattern={{major}}.{{minor}}
  type=semver,pattern={{major}}
  type=ref,event=branch
  type=ref,event=pr
  type=sha

Each entry is defined by a type, which are:

And global attributes:

  • enable=<true|false> enable this entry (default true)
  • priority=<number> set tag priority order
  • prefix=<string> add prefix
  • suffix=<string> add suffix

Default entries if tags input is empty:

tags: |
  type=schedule
  type=ref,event=branch
  type=ref,event=tag
  type=ref,event=pr

type=schedule

tags: |
  # minimal
  type=schedule
  # default
  type=schedule,pattern=nightly
  # handlebars
  type=schedule,pattern={{date 'YYYYMMDD'}}
  # handlebars with timezone
  type=schedule,pattern={{date 'YYYYMMDD-hhmmss' tz='Asia/Tokyo'}}

Will be used on schedule event.

pattern is a specially crafted attribute to support Handlebars' template with the following expressions:

  • date 'format' tz='Timezone' ; render date by its moment format. Default tz is UTC.
Pattern Output
nightly nightly
{{date 'YYYYMMDD'}} 20200110
{{date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}} 20200110-093000

Extended attributes and default values:

tags: |
  type=schedule,enable=true,priority=1000,prefix=,suffix=,pattern=nightly

type=semver

tags: |
  # minimal
  type=semver,pattern={{version}}
  # use custom value instead of git tag
  type=semver,pattern={{version}},value=v1.0.0

Will be used on a push tag event and requires a valid semver Git tag, but you can also use a custom value through value attribute.

pattern attribute supports Handlebars template with the following expressions:

  • raw ; the actual tag
  • version ; shorthand for {{major}}.{{minor}}.{{patch}} (can include pre-release)
  • major ; major version identifier
  • minor ; minor version identifier
  • patch ; patch version identifier
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*

*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 consumption.

Extended attributes and default values:

tags: |
  type=semver,enable=true,priority=900,prefix=,suffix=,pattern=,value=

type=pep440

tags: |
  # minimal
  type=pep440,pattern={{version}}
  # use custom value instead of git tag
  type=pep440,pattern={{version}},value=1.0.0

Will be used on a push tag event and requires a Git tag that conforms to PEP 440, but you can also use a custom value through value attribute.

pattern attribute supports Handlebars template with the following expressions:

  • raw ; the actual tag
  • version ; cleaned version
  • major ; major version identifier
  • minor ; minor version identifier
  • patch ; patch version identifier
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*

*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 consumption.

Extended attributes and default values:

tags: |
  type=pep440,enable=true,priority=900,prefix=,suffix=,pattern=,value=

type=match

tags: |
  # minimal
  type=match,pattern=\d.\d.\d
  # define match group
  type=match,pattern=v(.*),group=1
  # use custom value instead of git tag
  type=match,pattern=v(.*),group=1,value=v1.0.0

Can create a regular expression for matching Git tag with a pattern and capturing group. Will be used on a push tag event but, you can also use a custom value through value attribute.

Git tag Pattern Group Output
v1.2.3 \d.\d.\d 0 1.2.3
v2.0.8-beta.67 v(.*) 1 2.0.8-beta.67
v2.0.8-beta.67 v(\d.\d) 1 2.0
20200110-RC2 \d+ 0 20200110
p1/v1.2.3 p1/v(\d.\d.\d) 1 1.2.3

Extended attributes and default values:

tags: |
  type=match,enable=true,priority=800,prefix=,suffix=,pattern=,group=0,value=

type=edge

tags: |
  # minimal
  type=edge
  # define default branch
  type=edge,branch=main

An edge tag reflects the last commit of the active branch on your Git repository. I usually prefer to use edge as a Docker tag for a better distinction or common pattern. This is also used by official images like Alpine.

Extended attributes and default values:

tags: |
  type=edge,enable=true,priority=700,prefix=,suffix=,branch=$repo.default_branch

type=ref

tags: |
  # branch event
  type=ref,event=branch
  # tag event
  type=ref,event=tag
  # pull request event
  type=ref,event=pr

This type handles Git ref (or reference) for the following events:

  • branch ; eg. refs/heads/master
  • tag ; eg. refs/tags/v1.0.0
  • pr ; eg. refs/pull/318/merge
Event Ref Output
pull_request refs/pull/2/merge pr-2
push refs/heads/master master
push refs/heads/my/branch my-branch
push tag refs/tags/v1.2.3 v1.2.3
push tag refs/tags/v2.0.8-beta.67 v2.0.8-beta.67
workflow_dispatch refs/heads/master master

Extended attributes and default values:

tags: |
  # branch event
  type=ref,enable=true,priority=600,prefix=,suffix=,event=branch
  # tag event
  type=ref,enable=true,priority=600,prefix=,suffix=,event=tag
  # pull request event
  type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=pr

type=raw

tags: |
  type=raw,value=foo
  type=raw,value=bar
  # or
  type=raw,foo
  type=raw,bar
  # or
  foo
  bar

Output custom tags according to your needs.

Extended attributes and default values:

tags: |
  type=raw,enable=true,priority=200,prefix=,suffix=,value=

type=sha

tags: |
  # minimal (short sha)
  type=sha
  # full length sha
  type=sha,format=long

Output Git short commit (or long if specified) as Docker tag like sha-ad132f5.

Extended attributes and default values:

tags: |
  type=sha,enable=true,priority=100,prefix=sha-,suffix=,format=short

Notes

Image name and tag sanitization

In order to comply with the specification, the image name components may contain lowercase letters, digits and separators. A separator is defined as a period, one or two underscores, or one or more dashes. A name component may not start or end with a separator.

A tag name must be a valid ASCII chars sequences and may contain lowercase and uppercase letters, digits, underscores, periods and dashes. A tag name may not start with a period or a dash and may contain a maximum of 128 characters.

To ease the integration in your workflow, this action will automatically:

  • Lowercase the image name
  • Replace invalid chars sequences with - for tags

Latest tag

latest tag is handled through the flavor input. It will be generated by default (auto mode) for:

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:

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

You can also use the {{is_default_branch}} global expression to conditionally tag with latest for the default branch:

tags: |
  # set latest tag for default branch
  type=raw,value=latest,enable={{is_default_branch}}

priority attribute

priority=<int> attribute is used to sort tags in the final list. The higher the value, the higher the priority. The first tag in the list (higher priority) will be used as the image version for generated OCI label and version output. Each tags type attribute has a default priority:

Attribute Default priority
schedule 1000
semver 900
pep440 900
match 800
edge 700
ref 600
raw 200
sha 100

Global expressions

The following Handlebars' template expressions for prefix, suffix, value and enable attributes are available:

tags: |
  # dynamically set the branch name as a prefix
  type=sha,prefix={{branch}}-
  # dynamically set the branch name and sha as a custom tag
  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. We keep it for backward compatibility, but it's not recommended relying on it. More context in #192.

{{is_default_branch}}

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

{{date '<format>' tz='<timezone>'}}

Returns the current date rendered by its moment format. Default tz is UTC.

Expression Output example
{{date 'YYYYMMDD'}} 20200110
{{date 'dddd, MMMM Do YYYY, h:mm:ss a'}} Friday, January 10th 2020, 3:25:50 pm
{{date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}} 20200110-093000

Major version zero

Major version zero (0.y.z) is for initial development and may change at any time. This means the public API should not be considered stable.

In this case, Docker tag 0 should not be generated if you're using type=semver with {{major}} pattern. You can manage this behavior like this:

# refs/tags/v0.1.2
tags: |
  # output 0.1.2
  type=semver,pattern={{version}}
  # output 0.1
  type=semver,pattern={{major}}.{{minor}}
  # disabled if major zero
  type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}

JSON output object

The json output is a JSON object composed of the generated tags and labels so that you can reuse them further in your workflow using the fromJSON function:

      -
        name: Docker meta
        uses: docker/metadata-action@v5
        id: meta
        with:
          images: name/app
      -
        name: Build and push
        uses: docker/build-push-action@v5
        with:
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          build-args: |
            BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
            VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
            REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}

Overwrite labels and annotations

If some OCI Image Format Specification generated are not suitable as labels/annotations, you can overwrite them like this:

      -
        name: Docker meta
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: name/app
          labels: |
            maintainer=CrazyMax
            org.opencontainers.image.title=MyCustomTitle
            org.opencontainers.image.description=Another description
            org.opencontainers.image.vendor=MyCompany

Annotations

Since Buildx 0.12, it is possible to set annotations to your image through the --annotation flag.

With the build-push-action, you can set the annotations input with the value of the annotations output of the metadata-action:

      -
        name: Docker meta
        uses: docker/metadata-action@v5
        with:
          images: name/app
      -
        name: Build and push
        uses: docker/build-push-action@v5
        with:
          tags: ${{ steps.meta.outputs.tags }}
          annotations: ${{ steps.meta.outputs.annotations }}

The same can be done with the bake-action:

      -
        name: Docker meta
        uses: docker/metadata-action@v5
        with:
          images: name/app
      -
        name: Build
        uses: docker/bake-action@v4
        with:
          files: |
            ./docker-bake.hcl
            ${{ steps.meta.outputs.bake-file-tags }}
            ${{ steps.meta.outputs.bake-file-annotations }}
          targets: build

Note that annotations can be attached at many different levels within a manifest. By default, the generated annotations will be attached to image manifests, but different registries may expect annotations at different places; a common practice is to read annotations at image indexes if present, which are often used by multi-arch builds to index platform-specific images. If you want to specify level(s) for your annotations, you can use the DOCKER_METADATA_ANNOTATIONS_LEVELS environment variable with a comma separated list of all levels the annotations should be attached to (defaults to manifest). The following configuration demonstrates the ability to attach annotations to both image manifests and image indexes, though your registry may only need annotations at the index level. (That is, index alone may be enough.) Please consult the documentation of your registry.

      -
        name: Docker meta
        uses: docker/metadata-action@v5
        with:
          images: name/app
        env:
          DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
      -
        name: Build and push
        uses: docker/build-push-action@v5
        with:
          tags: ${{ steps.meta.outputs.tags }}
          annotations: ${{ steps.meta.outputs.annotations }}

More information about annotations in the BuildKit documentation.

Contributing

Want to contribute? Awesome! You can find information about contributing to this project in the CONTRIBUTING.md

metadata-action's People

Contributors

chroju avatar corburn avatar crazy-max avatar dependabot[bot] avatar dvdksn avatar favonia avatar felipecrs avatar frison avatar jakub-bacic avatar jasondamour avatar jgustie avatar neilime avatar stefanschoof avatar stigok avatar theo-brown avatar tonistiigi avatar venkytv avatar yano3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metadata-action's Issues

It is not possible to reproduce docker-build-push-action@v1 behavior

Behaviour

My configuration in V1 was: tag each commit to default branch as 'latest', and tag each git tag (e.g. 'v1.0.0') with v1.0.0 docker tag.
With V2 and this meta action everything is broken: when I push a git tag 'git push v1.0.0' I got 'v1.0.0' and 'latest' docker tags pointing to the same image. When I build an image on default branch without tag - 'latest' tag overwritten and pointing to some wrong image!

Steps to reproduce this issue

  1. This is my test Github repo with these actions - https://github.com/vitalyster/docker_build_action_hello
  2. This is what was published from master branch - https://hub.docker.com/repository/docker/vitalyster/hello/tags?page=1&ordering=last_updated

Expected behaviour

'latest' tag should point to '1.0.0' or 'master' tag (should be configurable)

Actual behaviour

I'm not sure what is going on with latest tag, it is unusable for me

FEATURE: enable support for conditional inclusing of each tag

Opening this in HackerHappyHour/tagging-strategy#42 as well


allow the use of ::true or ::false after each tag to specify whether or not that tag should be produced.

This will allow the use of expressions to determine whether or not a tag should be produced.

Here's a real example: you may want to produce the {{ major }} pattern under most conditions, but it doesn't
make sense to do so in the given tag is a pre-release. You could do something like:

-
  with:
    tags: |
      {{major}}::${{ github.event.action != 'prerelease' }}
      {{major}}.{{minor}}.{{patch}}

Make input variable names POSIX-compliant

Troubleshooting

Environment variables provided to the docker build push action through with that contain a '-' are not easily accessible, and are moreover not POSIX-compliant.

At the end, something like sep-tags is translated to INPUT_SEP-TAGS by the actions toolkit. Let's say that we need to set that environment variable depending of the output of other command using export INPUT_SEP-TAGS=\n, we can't.

Expected behaviour

Maybe is a good idea to switch to a underscore variable names like sep_tags, sep_labels and make all input names POSIX-compliant...

This is related to docker/build-push-action#404

Semver shouldnt publish tag `0`

Behaviour

Semver version 0.2 to 0.3 is breaking the same as 1 to 2.
Using tag 1 with only minor changes will not be breaking.
Using tag 0 will include breaking changes and should therefore not be used/published. (latest is there anyway)
The only benefit of using 0 over latest would be to prevent using 1 later on which seems like no benefit.

Steps to reproduce this issue

Publish tag v0.2.3 to a repo with config below.

Expected behaviour

Tags latest, 0.2 and 0.2.3 should be published.
Tag 0 should not be published.

Actual behaviour

Additionally tag 0 is published.

Configuration

uses: crazy-max/ghaction-docker-meta@v2
with:
  tags: |
    type=semver,pattern={{version}}
    type=semver,pattern={{major}}.{{minor}}
    type=semver,pattern={{major}}

Why are pull_request events set to skip docker push in the docs?

After going through all that trouble to run the job on PRs and come up with a beautiful little :pr-123 tag, in all the examples the push job config says push: ${{ github.event_name != 'pull_request' }}. It's the same on GitHub's build-and-push action docs, too.

Why is not pushing from PRs the default? What's the workflow useful for when pushing is disabled?

Feature: Add 'tag' input to allow creating tags based on upstream versions

I maintain several repositories where the docker repo is separate from the application repo. I wrote an action a while back HackerHappyHour/tagging-strategy that had a lot of the same intentions of this action, and I'd like to archive it in favor of this action.

The only feature my action has that isn't yet implemented here is the ability to (optionally) supply a tag value, instead of getting the tag from the repository.

This allows upstream repo's to dispatch on tagging/releases, and and for the docker repo to build/publish tags when that happens.

Example where we do this: github.com/OctoPrint/Octoprint triggers github.com/OctoPrint/octoprint-docker.

This goes especially well with #15, which was the other feature missing from this action, but seems like @hugopeixoto beat me to it!

I'd be willing to contribute this feature, just need approved suggestion on the input name. I'm thinking:

inputs:
  # other inputs
  input_tag:
    description: 'if provided will use the supplied value. Not compatible with all inputs (see README.md for compatibility)'
    required: false

Then for docs adding a 4th column in the inputs table in the README, specifying if compatible with input_tag, along with notes like

using input_tag is for scenarios when using external events to trigger builds is required such as repository_dispatch or workflow_dispatch

Feature: CLI

It would be awesome if we could have a CLI version with all these goodies, so we could use in CI/CD environments other than GitHub Actions, such as in Jenkins.

Add multiple tags based on semver

It would be great it this action could parse a semver tag and output multiple related docker tags.

Example: for version 1.2.3, the following tags would be set: 1, 1.2, 1.2.3 and latest

Generate `latest` version in push tag

Behaviour

Don't know why it doesn't generate latest version

Logs

Run crazy-max/ghaction-docker-meta@v1
  with:
    images: ghcr.io/xxxx/yyyy
    tag-latest: true
    tag-sha: true
    tag-semver: {{version}}
  {{major}}.{{minor}}
  
    tag-edge: false
    tag-match-group: 0
    tag-match-latest: true
    tag-schedule: nightly
    github-token: ***
  env:
    PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
Context info
  eventName: push
  sha: c9a937c5ec4cc425b0865804f5106fc4b06fe79f
  ref: refs/tags/v1.1.6-rc.1
  workflow: docker-build-release
  action: crazy-maxghaction-docker-meta
  actor: zero88
  runNumber: 4
  runId: 440078016
Docker image version
  1.1.6-rc.1
Docker tags
  ghcr.io/xxxx/yyyy:1.1.6-rc.1
  ghcr.io/xxxx/yyyy:sha-c9a937c
Docker labels
  org.opencontainers.image.title=yyyy
  org.opencontainers.image.description=
  org.opencontainers.image.url=https://github.com/xxxx/yyyy
  org.opencontainers.image.source=https://github.com/xxxx/yyyy
  org.opencontainers.image.version=1.1.6-rc.1
  org.opencontainers.image.created=2020-12-23T10:47:19.578Z
  org.opencontainers.image.revision=c9a937c5ec4cc425b0865804f5106fc4b06fe79f
  org.opencontainers.image.licenses=

Handling short version tags

Following up on #20, how would you suggest to produce tags v1, v1.6 and latest for v1.6 tag? The tag-match option can only generate one tag in addition to latest.

Using ref only for tag doesn't seem to work

Behaviour

Steps to reproduce this issue

  1. Use the image-meta action with the following tags config:

         type=edge,branch=master
         type=ref,event=branch,enable=false
         type=ref,event=tag
         type=sha,format=long,prefix=sha-
    

Expected behaviour

when building a branch on push (eg. cicd-github-actions)

I should get the sha- tag
I should not get the cicd-github-actions tag (it's a branch, I don't want the ref for that)

Actual behaviour

Getting both the sha and branch tags

Configuration

  • Repository URL (if public):
  • Build URL (if public):
      - name: Set image name
        id: image-name
        run: |
          echo "IMAGE_NAME=${ECR_ACCOUNT_ID}.dkr.ecr.ap-southeast-1.amazonaws.com/${ECR_IMAGE_NAME}" >> $GITHUB_ENV
          echo ::set-output name=image_name::${ECR_ACCOUNT_ID}.dkr.ecr.ap-southeast-1.amazonaws.com/${ECR_IMAGE_NAME}
      - name: Docker meta
        uses: docker/metadata-action@v3
        id: image-meta
        with:
          images: |
            ${{ steps.image-name.outputs.image_name }}
          tags: |
            type=edge,branch=master
            type=ref,event=branch,enable=false
            type=ref,event=tag
            type=sha,format=long,prefix=sha-

Logs

Download the log file of your build
and attach it to this issue.

Support environment variables for image name

I tried using the builtin variable ${github_repository/docker-/} (stripping prefix from name via bash variable manipulation) as the value for images. The build failed since it did not evaluate it (also tried with quotes).

My current workaround is to have a step before it to set it as a string output and then use that as the value e.g. ${{ steps.image_names.output.images }}

Comma separated list for pushing to multiple registries (docker hub and github container registry).

Would it be possible to add support for directly evaluating the variable? Or is it not good practice?

I reuse the same build workflow in my repos so I don't have to hardcode the names in each one.

Feature request: Set individual outputs per input flag

Currently, the outputs.tags gives a list of all the tags that were pushed. It would be useful if when, for example, a tag-sha is true, there was an outputs.tag-sha to accompany it. This would enable later steps to use a particular tag.

The motivation for this is a building an image of an application and picking a particular tag to use for generating a PR to bump the image tag in a Helm chart values.yaml

Latest not linked to the highest version

Behaviour

Steps to reproduce this issue

  1. I configure the metadata-action workflow in my repo with semantic version, as described in the instuctions
  2. I publish a new tag: v2.0.1 - this will trigger the action and a new Docker image will be generated with the following tags: 2.0.1, 2.0, 2 and latest
  3. Then I publish another tag: v1.9.1 - this will trigger the action and a new Docker image will be generated with the following tags: 1.9.1, 1.9, 1 and latest

Expected behaviour

I want to have the "latest" tag always linked to the highest version (v2.0.1)

Actual behaviour

If I publish a revision of an older version (v1.9.1) it will overwrite the "latest" version.

Is this deliberate? Is there any workaround?

Thanks

Enable attribute is ignored for tags

Behaviour

Global attribute enable for tags input (see docs) is ignored - even though it's set to "false", annotated tag is still created.

Steps to reproduce this issue

  1. Include enable=false in tags input, e.g.:
tags: |
  type=raw,value=foo
  type=raw,value=bar,enable=false
  1. Try to build/tag image.

Expected behaviour

List of docker tags should not include bar.

Actual behaviour

List of docker tags contains both foo and bar:

Logs

Run crazy-max/ghaction-docker-meta@v2
  with:
    images: testimage
    tags: type=raw,value=foo,
  type=raw,value=bar,enable=false
    github-token: ***

Context info
  eventName: pull_request
  sha: 99b0a688a109ec11aaafe1c3bf4c07296274ff32
  ref: refs/pull/1/merge
  workflow: CI
  action: crazy-maxghaction-docker-meta
  actor: jakub-bacic
  runNumber: 25
  runId: 700974690

Docker image version
  foo

Docker tags
  testimage:foo
  testimage:bar
...

Tags always include branch

output.tags always includes :branch

Steps to reproduce this issue

I use the following:

name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
  images: user/repo
  tag-sha: true

Expected behaviour

Only have a user/repo:tag-sha in the outputs.tags

Actual behaviour

outputs.tags contains

user/repo:main
user/repo:tag-sha

Is this the expected behavior? If it is, can the branch tag be removed with a simple setting and without resorting to filtering the output? Sorry if I missed something obvious! ๐Ÿ˜‰

Select/Change order of tags.

If you have latest and/or sha tagging enabled, then they get pushed to the registry last. Due to how github treats the last image pushed as the "latest" one, it shows it as first in every list and reference to that package.

This can get very confusing if you are looking at a list of packages e.g. here: https://github.com/orgs/restorecommerce/packages

It would be great if the latest and sha tags would be first in the list of tagged images, and the semver ones last. You could also provide an option to toggle this functionality or even pick the order.

Unless you have tag-match set, tag-match-latest does nothing on tag push.

Behaviour

Steps to reproduce this issue

  1. Set tag-match-latest: false without tag-match.
  2. Push a new tag
  3. Observe meta output includes latest tag.

Expected behaviour

Latest tag should be disableable without settings tag-match.

Actual behaviour

Latest tag is set when I wanted it to not be set.

name: Build Docker Image

on:
  push:
    tags:
      - 'v*.*.*'

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      -
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      -
        name: Docker meta
        id: docker_meta
        uses: crazy-max/ghaction-docker-meta@v1
        with:
          images: ${{ github.repository }}/web-noteskin-editor
          tag-sha: true
          tag-match-latest: false
      -
        name: Set up QEMU
        uses: docker/setup-qemu-action@v1
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      -
        name: Login to GitHub Container Registry
        uses: docker/login-action@v1 
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.CR_PAT }}
      -
        name: Build and Push
        uses: docker/build-push-action@v2
        with:
          context: .
          file: ./Dockerfile
          push: false
          tags: ${{ steps.docker_meta.outputs.tags }}
          labels: ${{ steps.docker_meta.outputs.labels }}

Logs

Docker tags
  flashflashrevolution/web-noteskin-editor/web-noteskin-editor:v0.0.1
  flashflashrevolution/web-noteskin-editor/web-noteskin-editor:latest
  flashflashrevolution/web-noteskin-editor/web-noteskin-editor:sha-f7fda8a

Note

The following config works as expected.

      -
        name: Docker meta
        id: docker_meta
        uses: crazy-max/ghaction-docker-meta@v1
        with:
          images: ${{ github.repository }}/web-noteskin-editor
          tag-match: v(.*)
          tag-sha: true
          tag-match-latest: false

latest/edge + default branch name as tag (v2)

Behaviour

Latest is also created in default branch and not only on tag creation.
Branch name is created in default branch if edge is enabled.

Steps to reproduce this issue

  1. Enable type=edge
  2. Enable type=ref,event=branch

Expected behaviour

Latest only if the run is in a tag.
Branch name if default branch only if edge is disabled.

Actual behaviour

see Behaviour

Configuration

      - name: Docker meta
        id: docker_meta
        uses: crazy-max/ghaction-docker-meta@v2
        with:
          images: |
            ${{ env.IMAGE_NAME }}
            ghcr.io/${{ env.IMAGE_NAME }}
          tags: |
            type=edge
            type=ref,event=pr
            type=ref,event=branch
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
          flavor: |
            suffix=-${{ matrix.jvm-impl }}
            latest=${{ matrix.jvm-impl == 'hotspot' }}

Logs

first: first.txt
second: second.txt

PS: Is there any way to check all existing tags to decide if the current tag is the latest or only a patch for an older tag?

Image not pushed on quay.io and not error reported during build step execution

Issue

The following step definition part of our repo is well executed but no image is pushed on Quay.io. Why: I dont know ;-)

Yaml step

-   name: Container meta
    id: container_meta
    uses: crazy-max/ghaction-docker-meta@v2
    with:
      # list of Docker images to use as base name for tags
      images: |
        quay.io/snowdrop/release-manager
      # generate Docker tags based on the following events/attributes
      tags: |
        type=semver,pattern={{version}}
        type=semver,pattern={{major}}.{{minor}}
        type=semver,pattern={{major}}
        type=sha
        type=ref,event=tag

-   name: Build and push
    id: container_build
    uses: docker/build-push-action@v2
    with:
      context: .
      file: ./ci/Dockerfile.jvm
      # tags: quay.io/snowdrop/release-manager:latest
      tags: ${{ steps.container_meta.outputs.tags }}
      labels: ${{ steps.container_meta.outputs.labels }}

-   name: Image digest
    run: echo ${{ steps.container_build.outputs.digest }}     

Job output

Run docker/build-push-action@v2
๐Ÿ“ฃ Buildx version: 0.5.1
๐Ÿƒ Starting build...
/usr/bin/docker buildx build --label org.opencontainers.image.title=release-manager --label org.opencontainers.image.description=Jira Java Client Tool --label org.opencontainers.image.url=https://github.com/snowdrop/release-manager --label org.opencontainers.image.source=https://github.com/snowdrop/release-manager --label org.opencontainers.image.version=sha-58f424e --label org.opencontainers.image.created=2021-04-26T14:16:01.932Z --label org.opencontainers.image.revision=58f424e5e37f648f6015b4b56b918c8c29dedd1c --label org.opencontainers.image.licenses= --tag quay.io/snowdrop/release-manager:sha-58f424e --iidfile /tmp/docker-build-push-ILfwct/iidfile --file ./ci/Dockerfile.jvm .
#1 [internal] load build definition from Dockerfile.jvm
#1 sha256:cdb3b0b91ca451d81c63a8c380d5124ff5624c0dada3c5071f74b5efade13684
#1 transferring dockerfile: 1.35kB done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 sha256:c4c5408536d9104e7346ca132db9215e808d0ac43b4952f94a425364ee2ceb04
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [internal] load metadata for registry.access.redhat.com/ubi8/ubi-minimal:8.1
#3 sha256:bedb5362f7f26505781fe7100b10933725e54b03283ed4f1ccb9efb7ee3caae4
#3 DONE 0.9s

#4 [1/4] FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1@sha256:df6f9e5d689e4a0b295ff12abc6e2ae2932a1f3e479ae1124ab76cf40c3a8cdd
#4 sha256:1988201fc2fbfd99229d9cdd22f5b7c1883d2c8c6f65c62cafb810795ad0a912
#4 resolve registry.access.redhat.com/ubi8/ubi-minimal:8.1@sha256:df6f9e5d689e4a0b295ff12abc6e2ae2932a1f3e479ae1124ab76cf40c3a8cdd done
#4 sha256:91d23a64fdf259ffce4181b40ce3dafa982a9e4a76ae6a88c1e662c6166c7324 4.46kB / 4.46kB done
#4 sha256:b26afdf22be4e9c30220796780a297b91549a3b3041b6fdcbda71bf48a6912e7 1.05MB / 34.67MB 0.2s
#4 sha256:218f593046abe6e9f194aed3fc2a2ad622065d6800175514dffa55dfce624b56 0B / 1.53kB 0.2s
#4 sha256:df6f9e5d689e4a0b295ff12abc6e2ae2932a1f3e479ae1124ab76cf40c3a8cdd 1.47kB / 1.47kB done
#4 sha256:4e6755fbb3af9502f60d7f0da12bad68217db3f92c2114f8867b76ac4e1d8bed 737B / 737B done
#4 ...

#6 [internal] load build context
#6 sha256:ec25ee7951fbbdaad92cb9aeee2b2901b644ffaed1ab03802752cdc101a38bcf
#6 transferring context: 38.67MB 0.4s done
#6 DONE 0.4s

#4 [1/4] FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1@sha256:df6f9e5d689e4a0b295ff12abc6e2ae2932a1f3e479ae1124ab76cf40c3a8cdd
#4 sha256:1988201fc2fbfd99229d9cdd22f5b7c1883d2c8c6f65c62cafb810795ad0a912
#4 sha256:b26afdf22be4e9c30220796780a297b91549a3b3041b6fdcbda71bf48a6912e7 5.24MB / 34.67MB 0.5s
#4 sha256:218f593046abe6e9f194aed3fc2a2ad622065d6800175514dffa55dfce624b56 1.53kB / 1.53kB 0.4s done
#4 sha256:b26afdf22be4e9c30220796780a297b91549a3b3041b6fdcbda71bf48a6912e7 9.44MB / 34.67MB 0.8s
#4 sha256:b26afdf22be4e9c30220796780a297b91549a3b3041b6fdcbda71bf48a6912e7 12.58MB / 34.67MB 1.0s
#4 sha256:b26afdf22be4e9c30220796780a297b91549a3b3041b6fdcbda71bf48a6912e7 15.73MB / 34.67MB 1.2s
#4 sha256:b26afdf22be4e9c30220796780a297b91549a3b3041b6fdcbda71bf48a6912e7 17.83MB / 34.67MB 1.3s
#4 sha256:b26afdf22be4e9c30220796780a297b91549a3b3041b6fdcbda71bf48a6912e7 20.97MB / 34.67MB 1.5s
#4 sha256:b26afdf22be4e9c30220796780a297b91549a3b3041b6fdcbda71bf48a6912e7 25.17MB / 34.67MB 1.8s
#4 sha256:b26afdf22be4e9c30220796780a297b91549a3b3041b6fdcbda71bf48a6912e7 27.26MB / 34.67MB 2.0s
#4 sha256:b26afdf22be4e9c30220796780a297b91549a3b3041b6fdcbda71bf48a6912e7 31.46MB / 34.67MB 2.2s
#4 sha256:b26afdf22be4e9c30220796780a297b91549a3b3041b6fdcbda71bf48a6912e7 33.55MB / 34.67MB 2.3s
#4 sha256:b26afdf22be4e9c30220796780a297b91549a3b3041b6fdcbda71bf48a6912e7 34.67MB / 34.67MB 2.5s done
#4 extracting sha256:b26afdf22be4e9c30220796780a297b91549a3b3041b6fdcbda71bf48a6912e7 0.1s
#4 extracting sha256:b26afdf22be4e9c30220796780a297b91549a3b3041b6fdcbda71bf48a6912e7 0.9s done
#4 extracting sha256:218f593046abe6e9f194aed3fc2a2ad622065d6800175514dffa55dfce624b56 done
#4 DONE 4.5s

#5 [2/4] RUN microdnf install curl wget ca-certificates java-11-openjdk-headless     && microdnf update     && microdnf clean all     && mkdir /deployments     && chown 1000 /deployments     && chmod "g+rwX" /deployments     && chown 1000:root /deployments     && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/1.3.8/run-java-sh-1.3.8-sh.sh -o /deployments/run-java.sh     && chown 1000 /deployments/run-java.sh     && chmod 755 /deployments/run-java.sh     && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security
#5 sha256:66a3e58d78c0e8bd79d173b0f3d8dc490ccb0609d84dd11fb6e1f01b5eda5bac
#5 0.257 
#5 0.257 (process:6): librhsm-WARNING **: 14:16:08.764: Found 0 entitlement certificates
#5 0.261 
#5 0.261 (process:6): librhsm-WARNING **: 14:16:08.768: Found 0 entitlement certificates
#5 0.261 
#5 0.261 (process:6): libdnf-WARNING **: 14:16:08.769: Loading "/etc/dnf/dnf.conf": IniParser: Can't open file
#5 0.317 Downloading metadata...
#5 1.016 Downloading metadata...
#5 2.232 Downloading metadata...
#5 2.905 Package                                                          Repository          Size
#5 2.905 Installing:                                                                              
#5 2.905  alsa-lib-1.2.3.2-1.el8.x86_64                                   ubi-8-appstream 480.2 kB
#5 2.905  avahi-libs-0.7-19.el8.x86_64                                    ubi-8-baseos     64.6 kB
#5 2.905  copy-jdk-configs-3.7-4.el8.noarch                               ubi-8-appstream  27.7 kB
#5 2.905  cups-libs-1:2.2.6-38.el8.x86_64                                 ubi-8-baseos    443.1 kB
#5 2.905  dbus-libs-1:1.12.8-12.el8_3.x86_64                              ubi-8-baseos    187.9 kB
#5 2.905  freetype-2.9.1-4.el8_3.1.x86_64                                 ubi-8-baseos    403.1 kB
#5 2.905  graphite2-1.3.10-10.el8.x86_64                                  ubi-8-appstream 124.5 kB
#5 2.905  harfbuzz-1.7.5-3.el8.x86_64                                     ubi-8-appstream 301.2 kB
#5 2.905  java-11-openjdk-headless-1:11.0.11.0.9-0.el8_3.x86_64           ubi-8-appstream  41.3 MB
#5 2.905  javapackages-filesystem-5.3.0-1.module+el8+2447+6f56d9a6.noarch ubi-8-appstream  31.1 kB
#5 2.905  lcms2-2.9-2.el8.x86_64                                          ubi-8-appstream 168.6 kB
#5 2.905  libjpeg-turbo-1.5.3-10.el8.x86_64                               ubi-8-appstream 159.2 kB
#5 2.905  libpng-2:1.6.34-5.el8.x86_64                                    ubi-8-baseos    129.0 kB
#5 2.905  lksctp-tools-1.0.18-3.el8.x86_64                                ubi-8-baseos    101.9 kB
#5 2.905  lua-5.3.4-11.el8.x86_64                                         ubi-8-appstream 197.4 kB
#5 2.905  nspr-4.25.0-2.el8_2.x86_64                                      ubi-8-appstream 145.5 kB
#5 2.905  nss-3.53.1-17.el8_3.x86_64                                      ubi-8-appstream 740.5 kB
#5 2.905  nss-softokn-3.53.1-17.el8_3.x86_64                              ubi-8-appstream 495.7 kB
#5 2.905  nss-softokn-freebl-3.53.1-17.el8_3.x86_64                       ubi-8-appstream 384.7 kB
#5 2.905  nss-sysinit-3.53.1-17.el8_3.x86_64                              ubi-8-appstream  74.0 kB
#5 2.905  nss-util-3.53.1-17.el8_3.x86_64                                 ubi-8-appstream 139.5 kB
#5 2.905  tzdata-java-2021a-1.el8.noarch                                  ubi-8-appstream 196.2 kB
#5 2.905  wget-1.19.5-10.el8.x86_64                                       ubi-8-appstream 751.3 kB
#5 2.905 Transaction Summary:
#5 2.905  Installing:       23 packages
#5 2.905  Reinstalling:      0 packages
#5 2.905  Upgrading:         0 packages
#5 2.905  Removing:          0 packages
#5 2.905  Downgrading:       0 packages
#5 2.962 Downloading packages...
#5 4.028 Running transaction test...
#5 4.465 Installing: nspr;4.25.0-2.el8_2;x86_64;ubi-8-appstream
#5 4.492 Installing: nss-util;3.53.1-17.el8_3;x86_64;ubi-8-appstream
#5 4.504 Installing: nss-softokn-freebl;3.53.1-17.el8_3;x86_64;ubi-8-appstream
#5 4.541 Installing: nss-softokn;3.53.1-17.el8_3;x86_64;ubi-8-appstream
#5 4.597 Installing: nss-sysinit;3.53.1-17.el8_3;x86_64;ubi-8-appstream
#5 4.604 Installing: nss;3.53.1-17.el8_3;x86_64;ubi-8-appstream
#5 4.678 Installing: tzdata-java;2021a-1.el8;noarch;ubi-8-appstream
#5 4.721 Installing: alsa-lib;1.2.3.2-1.el8;x86_64;ubi-8-appstream
#5 4.783 Installing: lcms2;2.9-2.el8;x86_64;ubi-8-appstream
#5 4.810 Installing: lua;5.3.4-11.el8;x86_64;ubi-8-appstream
#5 4.867 Installing: copy-jdk-configs;3.7-4.el8;noarch;ubi-8-appstream
#5 4.873 Installing: graphite2;1.3.10-10.el8;x86_64;ubi-8-appstream
#5 4.891 Installing: libjpeg-turbo;1.5.3-10.el8;x86_64;ubi-8-appstream
#5 4.914 Installing: javapackages-filesystem;5.3.0-1.module+el8+2447+6f56d9a6;noarch;ubi-8-appstream
#5 4.920 Installing: dbus-libs;1:1.12.8-12.el8_3;x86_64;ubi-8-baseos
#5 4.934 Installing: (null)
#5 4.944 Installing: avahi-libs;0.7-19.el8;x86_64;ubi-8-baseos
#5 4.950 Installing: (null)
#5 4.956 Installing: cups-libs;1:2.2.6-38.el8;x86_64;ubi-8-baseos
#5 4.990 Installing: (null)
#5 4.995 Installing: lksctp-tools;1.0.18-3.el8;x86_64;ubi-8-baseos
#5 5.006 Installing: (null)
#5 5.017 Installing: libpng;2:1.6.34-5.el8;x86_64;ubi-8-baseos
#5 5.027 Installing: (null)
#5 5.040 Installing: freetype;2.9.1-4.el8_3.1;x86_64;ubi-8-baseos
#5 5.075 Installing: (null)
#5 5.080 Installing: harfbuzz;1.7.5-3.el8;x86_64;ubi-8-appstream
#5 5.108 Installing: (null)
#5 5.119 Installing: java-11-openjdk-headless;1:11.0.11.0.9-0.el8_3;x86_64;ubi-8-appstream
#5 9.553 Installing: (null)
#5 10.01 Installing: wget;1.19.5-10.el8;x86_64;ubi-8-appstream
#5 10.08 Installing: (null)
#5 10.08 Installing: (null)
#5 10.30 Complete.
#5 10.33 
#5 10.33 (process:246): librhsm-WARNING **: 14:16:18.836: Found 0 entitlement certificates
#5 10.33 
#5 10.33 (process:246): librhsm-WARNING **: 14:16:18.840: Found 0 entitlement certificates
#5 10.33 
#5 10.33 (process:246): libdnf-WARNING **: 14:16:18.840: Loading "/etc/dnf/dnf.conf": IniParser: Can't open file
#5 10.38 Downloading metadata...
#5 10.61 Downloading metadata...
#5 10.91 Downloading metadata...
#5 11.22 Package                                                     Repository          Size
#5 11.22 Installing:                                                                         
#5 11.22  acl-2.2.53-1.el8.x86_64                                    ubi-8-baseos     83.0 kB
#5 11.22  cracklib-2.9.6-15.el8.x86_64                               ubi-8-baseos     95.5 kB
#5 11.22  cracklib-dicts-2.9.6-15.el8.x86_64                         ubi-8-baseos      4.1 MB
#5 11.22  crypto-policies-scripts-20210209-1.gitbfb6bed.el8_3.noarch ubi-8-baseos     68.8 kB
#5 11.22  cryptsetup-libs-2.3.3-2.el8.x86_64                         ubi-8-baseos    480.9 kB
#5 11.22  dbus-1:1.12.8-12.el8_3.x86_64                              ubi-8-baseos     41.7 kB
#5 11.22  dbus-common-1:1.12.8-12.el8_3.noarch                       ubi-8-baseos     46.5 kB
#5 11.22  dbus-daemon-1:1.12.8-12.el8_3.x86_64                       ubi-8-baseos    245.6 kB
#5 11.22  dbus-tools-1:1.12.8-12.el8_3.x86_64                        ubi-8-baseos     87.0 kB
#5 11.22  device-mapper-8:1.02.171-5.el8_3.2.x86_64                  ubi-8-baseos    382.2 kB
#5 11.22  device-mapper-libs-8:1.02.171-5.el8_3.2.x86_64             ubi-8-baseos    415.5 kB
#5 11.22  diffutils-3.6-6.el8.x86_64                                 ubi-8-baseos    367.4 kB
#5 11.22  elfutils-default-yama-scope-0.180-1.el8.noarch             ubi-8-baseos     49.7 kB
#5 11.22  elfutils-libs-0.180-1.el8.x86_64                           ubi-8-baseos    299.9 kB
#5 11.22  file-libs-5.33-16.el8_3.1.x86_64                           ubi-8-baseos    555.7 kB
#5 11.22  gdbm-1:1.18-1.el8.x86_64                                   ubi-8-baseos    132.9 kB
#5 11.22  gdbm-libs-1:1.18-1.el8.x86_64                              ubi-8-baseos     62.0 kB
#5 11.22  glibc-langpack-en-2.28-127.el8_3.2.x86_64                  ubi-8-baseos    844.0 kB
#5 11.22  gnupg2-smime-2.2.20-2.el8.x86_64                           ubi-8-baseos    289.9 kB
#5 11.22  gzip-1.9-9.el8.x86_64                                      ubi-8-baseos    170.9 kB
#5 11.22  iptables-libs-1.8.4-15.el8_3.3.x86_64                      ubi-8-baseos    108.9 kB
#5 11.22  kmod-libs-25-16.el8_3.1.x86_64                             ubi-8-baseos     69.9 kB
#5 11.22  libfdisk-2.32.1-24.el8.x86_64                              ubi-8-baseos    255.3 kB
#5 11.22  libmodulemd-2.9.4-2.el8.x86_64                             ubi-8-baseos    193.2 kB
#5 11.22  libnsl2-1.2.0-2.20180605git4a062cf.el8.x86_64              ubi-8-baseos     59.1 kB
#5 11.22  libpcap-14:1.9.1-4.el8.x86_64                              ubi-8-baseos    170.4 kB
#5 11.22  libpwquality-1.4.0-9.el8.x86_64                            ubi-8-baseos    105.0 kB
#5 11.22  libseccomp-2.4.3-1.el8.x86_64                              ubi-8-baseos     68.6 kB
#5 11.22  libsecret-0.18.6-1.el8.x86_64                              ubi-8-baseos    166.9 kB
#5 11.22  libsemanage-2.9-3.el8.x86_64                               ubi-8-baseos    168.6 kB
#5 11.22  libtirpc-1.1.4-4.el8.x86_64                                ubi-8-baseos    115.5 kB
#5 11.22  libutempter-1.1.6-14.el8.x86_64                            ubi-8-baseos     32.6 kB
#5 11.22  libxkbcommon-0.9.1-1.el8.x86_64                            ubi-8-appstream 118.5 kB
#5 11.22  libzstd-1.4.4-1.el8.x86_64                                 ubi-8-baseos    272.4 kB
#5 11.22  openssl-1:1.1.1g-15.el8_3.x86_64                           ubi-8-baseos    723.9 kB
#5 11.22  openssl-pkcs11-0.4.10-2.el8.x86_64                         ubi-8-baseos     67.5 kB
#5 11.22  pam-1.3.1-11.el8.x86_64                                    ubi-8-baseos    755.9 kB
#5 11.22  pinentry-1.1.0-2.el8.x86_64                                ubi-8-appstream 102.3 kB
#5 11.22  platform-python-3.6.8-31.el8.x86_64                        ubi-8-baseos     85.3 kB
#5 11.22  platform-python-pip-9.0.3-18.el8.noarch                    ubi-8-baseos      1.8 MB
#5 11.22  platform-python-setuptools-39.2.0-6.el8.noarch             ubi-8-baseos    647.5 kB
#5 11.22  python3-libs-3.6.8-31.el8.x86_64                           ubi-8-baseos      8.2 MB
#5 11.22  python3-pip-wheel-9.0.3-18.el8.noarch                      ubi-8-baseos      1.1 MB
#5 11.22  python3-setuptools-wheel-39.2.0-6.el8.noarch               ubi-8-baseos    295.8 kB
#5 11.22  shadow-utils-2:4.6-11.el8.x86_64                           ubi-8-baseos      1.3 MB
#5 11.22  shared-mime-info-1.9-3.el8.x86_64                          ubi-8-baseos    336.4 kB
#5 11.22  systemd-239-41.el8_3.2.x86_64                              ubi-8-baseos      3.7 MB
#5 11.22  systemd-pam-239-41.el8_3.2.x86_64                          ubi-8-baseos    467.3 kB
#5 11.22  trousers-0.3.14-4.el8.x86_64                               ubi-8-baseos    156.5 kB
#5 11.22  trousers-lib-0.3.14-4.el8.x86_64                           ubi-8-baseos    172.4 kB
#5 11.22  util-linux-2.32.1-24.el8.x86_64                            ubi-8-baseos      2.6 MB
#5 11.22  xkeyboard-config-2.28-1.el8.noarch                         ubi-8-appstream 801.0 kB
#5 11.22 Upgrading:                                                                          
#5 11.22  audit-libs-3.0-0.17.20191104git1c2f876.el8.x86_64          ubi-8-baseos    119.2 kB
#5 11.22  bash-4.4.19-12.el8.x86_64                                  ubi-8-baseos      1.6 MB
#5 11.22  brotli-1.0.6-2.el8.x86_64                                  ubi-8-baseos    330.1 kB
#5 11.22  ca-certificates-2020.2.41-80.0.el8_2.noarch                ubi-8-baseos    400.4 kB
#5 11.22  chkconfig-1.13-2.el8.x86_64                                ubi-8-baseos    198.7 kB
#5 11.22  coreutils-single-8.30-8.el8.x86_64                         ubi-8-baseos    642.2 kB
#5 11.22  crypto-policies-20210209-1.gitbfb6bed.el8_3.noarch         ubi-8-baseos     63.6 kB
#5 11.22  curl-7.61.1-14.el8_3.1.x86_64                              ubi-8-baseos    361.3 kB
#5 11.22  cyrus-sasl-lib-2.1.27-5.el8.x86_64                         ubi-8-baseos    126.2 kB
#5 11.22  elfutils-libelf-0.180-1.el8.x86_64                         ubi-8-baseos    219.7 kB
#5 11.22  expat-2.2.5-4.el8.x86_64                                   ubi-8-baseos    113.6 kB
#5 11.22  filesystem-3.8-3.el8.x86_64                                ubi-8-baseos      1.1 MB
#5 11.22  glib2-2.56.4-8.el8.x86_64                                  ubi-8-baseos      2.6 MB
#5 11.22  glibc-2.28-127.el8_3.2.x86_64                              ubi-8-baseos      3.8 MB
#5 11.22  glibc-common-2.28-127.el8_3.2.x86_64                       ubi-8-baseos      1.4 MB
#5 11.22  glibc-minimal-langpack-2.28-127.el8_3.2.x86_64             ubi-8-baseos     55.1 kB
#5 11.22  gnupg2-2.2.20-2.el8.x86_64                                 ubi-8-baseos      2.5 MB
#5 11.22  gnutls-3.6.14-8.el8_3.x86_64                               ubi-8-baseos      1.0 MB
#5 11.22  gpgme-1.13.1-3.el8.x86_64                                  ubi-8-baseos    343.3 kB
#5 11.22  info-6.5-6.el8.x86_64                                      ubi-8-baseos    203.0 kB
#5 11.22  krb5-libs-1.18.2-5.el8.x86_64                              ubi-8-baseos    857.3 kB
#5 11.22  libarchive-3.3.2-9.el8.x86_64                              ubi-8-baseos    366.4 kB
#5 11.22  libblkid-2.32.1-24.el8.x86_64                              ubi-8-baseos    221.2 kB
#5 11.22  libcap-2.26-4.el8.x86_64                                   ubi-8-baseos     61.3 kB
#5 11.22  libcap-ng-0.7.9-5.el8.x86_64                               ubi-8-baseos     34.1 kB
#5 11.22  libcom_err-1.45.6-1.el8.x86_64                             ubi-8-baseos     50.1 kB
#5 11.22  libcurl-7.61.1-14.el8_3.1.x86_64                           ubi-8-baseos    305.8 kB
#5 11.22  libdb-5.3.28-39.el8.x86_64                                 ubi-8-baseos    767.9 kB
#5 11.22  libdb-utils-5.3.28-39.el8.x86_64                           ubi-8-baseos    152.7 kB
#5 11.22  libdnf-0.48.0-5.el8.x86_64                                 ubi-8-baseos    665.9 kB
#5 11.22  libffi-3.1-22.el8.x86_64                                   ubi-8-baseos     38.1 kB
#5 11.22  libgcc-8.3.1-5.1.el8.x86_64                                ubi-8-baseos     80.1 kB
#5 11.22  libgcrypt-1.8.5-4.el8.x86_64                               ubi-8-baseos    473.7 kB
#5 11.22  libmodulemd1-1.8.16-0.2.9.4.2.x86_64                       ubi-8-baseos    180.3 kB
#5 11.22  libmount-2.32.1-24.el8.x86_64                              ubi-8-baseos    237.4 kB
#5 11.22  libnghttp2-1.33.0-3.el8_2.1.x86_64                         ubi-8-baseos     79.2 kB
#5 11.22  libpsl-0.20.2-6.el8.x86_64                                 ubi-8-baseos     62.9 kB
#5 11.22  librepo-1.12.0-2.el8.x86_64                                ubi-8-baseos     92.6 kB
#5 11.22  libselinux-2.9-4.el8_3.x86_64                              ubi-8-baseos    169.1 kB
#5 11.22  libsmartcols-2.32.1-24.el8.x86_64                          ubi-8-baseos    179.4 kB
#5 11.22  libsolv-0.7.11-1.el8.x86_64                                ubi-8-baseos    368.1 kB
#5 11.22  libssh-0.9.4-2.el8.x86_64                                  ubi-8-baseos    219.7 kB
#5 11.22  libssh-config-0.9.4-2.el8.noarch                           ubi-8-baseos     18.9 kB
#5 11.22  libstdc++-8.3.1-5.1.el8.x86_64                             ubi-8-baseos    461.8 kB
#5 11.22  libusbx-1.0.23-4.el8.x86_64                                ubi-8-baseos     76.1 kB
#5 11.22  libuuid-2.32.1-24.el8.x86_64                               ubi-8-baseos     97.0 kB
#5 11.22  libxml2-2.9.7-8.el8.x86_64                                 ubi-8-baseos    712.5 kB
#5 11.22  lz4-libs-1.8.3-2.el8.x86_64                                ubi-8-baseos     67.2 kB
#5 11.22  microdnf-3.4.0-1.el8.x86_64                                ubi-8-baseos     46.3 kB
#5 11.22  nettle-3.4.1-4.el8_3.x86_64                                ubi-8-baseos    307.8 kB
#5 11.22  openldap-2.4.46-15.el8.x86_64                              ubi-8-baseos    359.9 kB
#5 11.22  openssl-libs-1:1.1.1g-15.el8_3.x86_64                      ubi-8-baseos      1.5 MB
#5 11.22  pcre2-10.32-2.el8.x86_64                                   ubi-8-baseos    252.3 kB
#5 11.22  redhat-release-8.3-1.0.el8.x86_64                          ubi-8-baseos     41.7 kB
#5 11.22  rpm-4.14.3-4.el8.x86_64                                    ubi-8-baseos    553.6 kB
#5 11.22  rpm-libs-4.14.3-4.el8.x86_64                               ubi-8-baseos    346.4 kB
#5 11.22  sed-4.5-2.el8.x86_64                                       ubi-8-baseos    305.0 kB
#5 11.22  setup-2.12.2-6.el8.noarch                                  ubi-8-baseos    185.0 kB
#5 11.22  sqlite-libs-3.26.0-11.el8.x86_64                           ubi-8-baseos    594.0 kB
#5 11.22  systemd-libs-239-41.el8_3.2.x86_64                         ubi-8-baseos      1.1 MB
#5 11.22  tzdata-2021a-1.el8.noarch                                  ubi-8-baseos    484.0 kB
#5 11.22  zlib-1.2.11-16.2.el8_3.x86_64                              ubi-8-baseos    104.7 kB
#5 11.22 Transaction Summary:
#5 11.22  Installing:       52 packages
#5 11.22  Reinstalling:      0 packages
#5 11.22  Upgrading:        62 packages
#5 11.22  Removing:          0 packages
#5 11.22  Downgrading:       0 packages
#5 11.28 Downloading packages...
#5 12.97 Running transaction test...
#5 14.04 Updating: libgcc;8.3.1-5.1.el8;x86_64;ubi-8-baseos
...
#5 24.77 Complete.
#5 24.82 
#5 24.82 (microdnf:596): librhsm-WARNING **: 14:16:33.326: Found 0 entitlement certificates
#5 24.82 
#5 24.82 (microdnf:596): librhsm-WARNING **: 14:16:33.329: Found 0 entitlement certificates
#5 24.83 Complete.
#5 24.85   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#5 24.85                                  Dload  Upload   Total   Spent    Left  Speed
#5 24.85 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 20218  100 20218    0     0   759k      0 --:--:-- --:--:-- --:--:--  759k
#5 DONE 26.9s

#7 [3/4] COPY target/lib/* /deployments/lib/
#7 sha256:b467325bcd32959ce316cbb1d2ed7067072f4d0a250b72200983098942f95a29
#7 DONE 0.2s

#8 [4/4] COPY target/*-runner.jar /deployments/app.jar
#8 sha256:01ec8d5737343a5237ae305d3c64a6338d0f2ac2a7018ecc115e198d20e09186
#8 DONE 0.0s

#9 exporting to image
#9 sha256:e8c613e07b0b7ff33893b694f7759a10d42e180f2b4dc349fb57dc6b71dcab00
#9 exporting layers
#9 exporting layers 3.1s done
#9 writing image sha256:f3de3c5da30c2d31c6d3da86bea70a1424147e53470daa48522d759c974caca1 done
#9 naming to quay.io/snowdrop/release-manager:sha-58f424e done
#9 DONE 3.2s
๐Ÿ›’ Extracting digest...
sha256:f3de3c5da30c2d31c6d3da86bea70a1424147e53470daa48522d759c974caca1

Support pull_request_target event in same way as pull_request

Behaviour

Currently, metadata-action creates tags like pr-XXX when used in a GitHub Action triggered by the pull_request event. This means when using pull requests inside a repository you can publish "preview" docker images which can then be inspected / tested by other GitHub Actions or the pull request reviewers.

However, when a pull request is sent from a forked repository (such as when groups are using the "fork and pull" model), the pull_request event does not have access to things like the secrets nor write access -- this means that you can't push these pr-XXX tags.

To solve this issue, GitHub created the pull_request_target event, which runs on pull requests using the workflow configuration from the primary repository (see https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/ and https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target).

However, when using the pull_request_target the metadata-action instead generates a tag of the upstream branch name. Instead it should generate the same style of tags as pull_request.

Steps to reproduce this issue

  1. Use metadata-action in a GitHub Action triggered by pull_request_target.

Expected behaviour

Create tags based on the pull request number like pr-XXX.

Actual behaviour

Create tags based on the upstream branch name.

Configuration

  • Repository URL (if public):
  • Build URL (if public):
on:
  pull_request:
  pull_request_target:

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
    - name: Docker meta
      id: docker_meta
      uses: docker/metadata-action@v3
      with:
        tags: |
          type=ref,event=tag
          type=ref,event=pr
          type=ref,event=branch
          type=sha
          type=sha,format=long

Logs

pull_request example

Context info
  eventName: pull_request_target
  sha: 7e536a20216d13ae89e82f4f0040889c53062158
  ref: refs/heads/upstream-main
  workflow: Build Docker Image for Run DRC for cell GDS (using Magic) Action
  action: dockermetadata-action
  actor: mithro
  runNumber: 40
  runId: 867571226
Processing tags input
  type=ref,event=tag,enable=true,priority=600
  type=ref,event=pr,prefix=pr-,enable=true,priority=600
  type=ref,event=branch,enable=true,priority=600
  type=sha,prefix=sha-,format=short,enable=true,priority=100
  type=sha,format=long,prefix=sha-,enable=true,priority=100
Processing flavor input
  latest=auto
  prefix=
  suffix=
Docker image version
  upstream-main
Docker tags
  localhost:5000/run-drc-for-cell-gds-using-magic:upstream-main
  localhost:5000/run-drc-for-cell-gds-using-magic:sha-7e536a2
  localhost:5000/run-drc-for-cell-gds-using-magic:sha-7e536a20216d13ae89e82f4f0040889c53062158
  gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:upstream-main
  gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:sha-7e536a2
  gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:sha-7e536a20216d13ae89e82f4f0040889c53062158

pull_request_target example

Context info
  eventName: pull_request
  sha: 5427096b63e64959becdba7da5a713a69205bc11
  ref: refs/pull/4/merge
  workflow: Build Docker Image for Run DRC for cell GDS (using Magic) Action
  action: dockermetadata-action
  actor: mithro
  runNumber: 36
  runId: 867535443
Processing tags input
  type=ref,event=tag,enable=true,priority=600
  type=ref,event=pr,prefix=pr-,enable=true,priority=600
  type=ref,event=branch,enable=true,priority=600
  type=sha,prefix=sha-,format=short,enable=true,priority=100
  type=sha,format=long,prefix=sha-,enable=true,priority=100
Processing flavor input
Docker image version
  pr-4
Docker tags
  localhost:5000/run-drc-for-cell-gds-using-magic:pr-4
  localhost:5000/run-drc-for-cell-gds-using-magic:sha-5427096
  localhost:5000/run-drc-for-cell-gds-using-magic:sha-5427096b63e64959becdba7da5a713a69205bc11
  gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:pr-4
  gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:sha-5427096
  gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:sha-5427096b63e64959becdba7da5a713a69205bc11

semver based on branch names

I'd like to kick off semver tags based on git branch names, as opposed to git tag names.

For example:

push refs/heads/release/v1.2.3 1.2.3, 1.2

It doesn't seem like this is possible with type=semver since that only works on git tags. type=pattern likewise doesn't apply. type=ref,event=branch, while applying to branches, doesn't allow custom patterns.

Any help would be much appreciated!

Is there a variable for branch?

Is there a way to do the branch name dynamically as the prefix?

type=sha,prefix=${{ branch_name}}-,suffix=,enable=true

Something like that ^

Question: How to retrieve the sha tag for later usage.

Thanks for your work,

How do you expect the usage of the commit sha tag in for example a deploy step?

The outputs.tags is very useful to docker build, but what's the best way to use the sha tag without interpolations?

Docker tags
ย  regist.ry/app:my-branch
ย  regist.ry/app:sha-50fb88d

I want to use regist.ry/app:sha-50fb88d in another step:

  - name: Example deploy
    run: deploy **regist.ry/app:sha-50fb88d**

Thank you

`onlatest:true` don't add pre or suffix on `latest` tag

Behaviour

Steps to reproduce this issue

Look to https://github.com/Secure-Compliance-Solutions-LLC/GVM-Docker/runs/3182377485?check_suite_focus=true

Expected behaviour

The latest tag should have the suffix appended

Actual behaviour

The latest tag has no suffix

Configuration

name: Docker Image Build and Release

on:
  push:
    branches: [master]
  pull_request:
    branches: [master, dev]
  create:
    tags:

concurrency: ci-${{ github.ref }}

env:
  # Use docker.io for Docker Hub if empty
  REGISTRY: ghcr.io
  # github.repository as <account>/<repo>
  IMAGE_NAME: ${{ github.repository }}
  IMAGE_NAME_GHCR: ghcr.io/${{ github.repository }}
  IMAGE_NAME_DOCKER: securecompliance/gvm

permissions:
  contents: read
  packages: write

jobs:
  build_test:
    name: Build and Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set tag var
        id: vars
        run: echo ::set-output name=docker_tag::$(echo ${GITHUB_REF} | cut -d'/' -f3)-${GITHUB_SHA}

      - name: Download artifact
        uses: dawidd6/action-download-artifact@v2
        with:
          # Optional, GitHub token, a Personal Access Token with `public_repo` scope if needed
          # Required, if artifact is from a different repo
          github_token: ${{secrets.GITHUB_TOKEN}}
          # Required, workflow file name or ID
          workflow: build-apk.yml
          # Optional, will use the branch
          branch: master
          # Optional, uploaded artifact name,
          # will download all artifacts if not specified
          # and extract them in respective subdirectories
          # https://github.com/actions/download-artifact#download-all-artifacts
          name: apk-builds
          # Optional, directory where to extract artifact. Defaults to the artifact name (see `name` input)
          path: ${{ github.workspace }}/apk-build/
          # Optional, defaults to current repo
          repo: Secure-Compliance-Solutions-LLC/GVM-APK-build

      - name: Build the Docker image
        run: docker build . --file Dockerfile --build-arg OPT_PDF=1 --tag myapp:${{ steps.vars.outputs.docker_tag }}

      - name: Scan with Phonito Security
        uses: phonito/phonito-scanner-action@master
        with:
          image: myapp:${{ steps.vars.outputs.docker_tag }}
          phonito-token: ${{ secrets.PHONITO_TOKEN }}

  build_release:
    name: Build and Release
    runs-on: ubuntu-latest

    outputs:
      labels: ${{ steps.meta.outputs.labels }}
      tags: ${{ steps.meta.outputs.tags }}

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          submodules: recursive

      - uses: docker/setup-buildx-action@v1
        id: buildx
        with:
          install: true

      # Login against a Docker registry except on PR
      # https://github.com/docker/login-action
      - name: Login to GitHub Container Registry ${{ env.REGISTRY }}
        uses: docker/login-action@v1
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Login to DockerHub
        if: github.event_name != 'pull_request'
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Relase Prepare for latest Tag
        id: releasePreareLatestTag
        shell: bash
        run: |
          if [[ "$GITHUB_EVENT_NAME" == "create" ]] && [[ "$GITHUB_REF" =~ ^refs/tags/v.* ]]; then
            echo -n "::set-output name=latest::true"
          else
            echo -n "::set-output name=latest::false"
          fi
      - name: Relase Prepare
        id: releasePreare
        run: |
          echo -n "::set-output name=images::"
          if [ "${GITHUB_EVENT_NAME}" != "pull_request" ]; then
            echo -n "${IMAGE_NAME_DOCKER}"
            echo -n ","
          fi
          echo -n "${IMAGE_NAME_GHCR}"
      - name: Download artifact
        uses: dawidd6/action-download-artifact@v2
        with:
          # Optional, GitHub token, a Personal Access Token with `public_repo` scope if needed
          # Required, if artifact is from a different repo
          github_token: ${{secrets.GITHUB_TOKEN}}
          # Required, workflow file name or ID
          workflow: build-apk.yml
          # Optional, will use the branch
          branch: master
          # Optional, uploaded artifact name,
          # will download all artifacts if not specified
          # and extract them in respective subdirectories
          # https://github.com/actions/download-artifact#download-all-artifacts
          name: apk-builds
          # Optional, directory where to extract artifact. Defaults to the artifact name (see `name` input)
          path: ${{ github.workspace }}/apk-build/
          # Optional, defaults to current repo
          repo: Secure-Compliance-Solutions-LLC/GVM-APK-build

      # Extract metadata (tags, labels) for Docker
      # https://github.com/docker/metadata-action
      - name: Extract Docker metadata
        id: meta2
        uses: docker/metadata-action@v3
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          images: ${{ steps.releasePreare.outputs.images }}
          flavor: |
            latest=${{ steps.releasePreareLatestTag.outputs.latest}}
            prefix=
            suffix=
          tags: |
            type=ref,event=branch
            type=ref,event=pr
            type=semver,pattern={{version}}
            type=semver,pattern={{raw}}
            type=semver,pattern={{major}}.{{minor}}
      # Build and push Docker image with Buildx (don't push on PR)
      # https://github.com/docker/build-push-action
      - name: Build and push Docker image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          tags: ${{ steps.meta2.outputs.tags }}
          labels: ${{ steps.meta2.outputs.labels }}
          build-args: |
            SETUP=0
      # Extract metadata (tags, labels) for Docker
      # https://github.com/docker/metadata-action
      - name: Extract Docker metadata
        id: meta3
        uses: docker/metadata-action@v3
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          images: ${{ steps.releasePreare.outputs.images }}
          flavor: |
            latest=${{ steps.releasePreareLatestTag.outputs.latest}}
            onlatest=${{ steps.releasePreareLatestTag.outputs.latest}}
            prefix=
            suffix=-full
          tags: |
            type=ref,event=branch
            type=ref,event=tag
            type=ref,event=pr
            type=semver,pattern={{version}}
            type=semver,pattern={{raw}}
            type=semver,pattern={{major}}.{{minor}}
      # Build and push Docker image with Buildx (don't push on PR)
      # https://github.com/docker/build-push-action
      - name: Build and push Docker image -full tag
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          tags: ${{ steps.meta3.outputs.tags }}
          labels: ${{ steps.meta3.outputs.labels }}
          build-args: |
            SETUP=0
            OPT_PDF=1
      # Extract metadata (tags, labels) for Docker
      # https://github.com/docker/metadata-action
      - name: Extract Docker metadata
        id: meta4
        uses: docker/metadata-action@v3
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          images: ${{ steps.releasePreare.outputs.images }}
          flavor: |
            latest=${{ steps.releasePreareLatestTag.outputs.latest}}
            onlatest=${{ steps.releasePreareLatestTag.outputs.latest}}
            prefix=
            suffix=-data
          tags: |
            type=ref,event=branch
            type=ref,event=pr
            type=semver,pattern={{version}}
            type=semver,pattern={{raw}}
            type=semver,pattern={{major}}.{{minor}}
      # Build and push Docker image with Buildx (don't push on PR)
      # https://github.com/docker/build-push-action
      - name: Build and push Docker image with -data tag
        uses: docker/build-push-action@v2
        with:
          context: .
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.meta4.outputs.tags }}
          labels: ${{ steps.meta4.outputs.labels }}
          build-args: |
            SETUP=1
      # Extract metadata (tags, labels) for Docker
      # https://github.com/docker/metadata-action
      - name: Extract Docker metadata
        id: meta5
        uses: docker/metadata-action@v3
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          images: ${{ steps.releasePreare.outputs.images }}
          flavor: |
            latest=${{ steps.releasePreareLatestTag.outputs.latest}}
            onlatest=${{ steps.releasePreareLatestTag.outputs.latest}}
            prefix=
            suffix=-data-full
          tags: |
            type=ref,event=branch
            type=ref,event=pr
            type=semver,pattern={{version}}
            type=semver,pattern={{raw}}
            type=semver,pattern={{major}}.{{minor}}
      # Build and push Docker image with Buildx (don't push on PR)
      # https://github.com/docker/build-push-action
      - name: Build and push Docker image with -data-full tag
        uses: docker/build-push-action@v2
        with:
          context: .
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.meta5.outputs.tags }}
          labels: ${{ steps.meta5.outputs.labels }}
          build-args: |
            SETUP=1
            OPT_PDF=1

Logs

logs_61.zip

Flavor suffix does not append to latest tag

Behaviour

When using a flavor suffix, it will not be appended to the latest tag

Steps to reproduce this issue

  1. Set up metadata-action to use any flavor suffix
  2. Push a tag to trigger the latest tag release
  3. Watch as the suffix is not appended to the latest tag

Expected behaviour

Flavor suffix should be appended to the suffix

Actual behaviour

Creates the latest tag without the suffix

Configuration

# ommited irreverent steps
jobs:
  Slim:
    runs-on: ubuntu-latest
    steps:

    - name: Checkout
      uses: actions/checkout@v2

    - name: Docker Meta
      id: meta
      uses: docker/metadata-action@v3
      with:
        images: cyb3rjak3/pypy-flask,ghcr.io/cyb3r-jak3/pypy-flask,registry.gitlab.com/cyb3r-jak3/pypy-flask
        tags: |
          type=ref,event=pr
          type=semver,pattern={{version}}
          type=semver,pattern={{major}}.{{minor}}
          type=sha
        labels: |
          org.label-schema.vcs-url=https://github.com/Cyb3r-Jak3/pypy-flask.git
          org.label-schema.schema-version=1.0.0-rc1

    - name: Slim Build and Push
      uses: docker/[email protected]
      with:
        platforms: linux/amd64,linux/arm64
        cache-from: type=local,src=/tmp/.buildx-cache
        cache-to: type=local,dest=/tmp/.buildx-cache
        push: ${{ startsWith(github.ref, 'refs/tags/v') }}
        file: Dockerfile
        tags: ${{ steps.meta.outputs.tags }}
        labels: ${{ steps.meta.outputs.labels }}

  Alpine:
    runs-on: ubuntu-latest
    steps:

    - name: Checkout
      uses: actions/checkout@v2

    - name: Docker Meta
      id: meta
      uses: docker/metadata-action@v3
      with:
        images: cyb3rjak3/pypy-flask,ghcr.io/cyb3r-jak3/pypy-flask,registry.gitlab.com/cyb3r-jak3/pypy-flask
        flavor: |
          suffix=-alpine
        tags: |
          type=ref,event=pr
          type=semver,pattern={{version}}
          type=semver,pattern={{major}}.{{minor}}
          type=sha
        labels: |
          org.label-schema.vcs-url=https://github.com/Cyb3r-Jak3/pypy-flask.git
          org.label-schema.schema-version=1.0.0-rc1

    - name: Alpine Build and Push
      uses: docker/[email protected]
      with:
        platforms: linux/amd64,linux/arm64
        cache-from: type=local,src=/tmp/.buildx-cache
        cache-to: type=local,dest=/tmp/.buildx-cache
        push: ${{ startsWith(github.ref, 'refs/tags/v') }}
        file: alpine.Dockerfile
        tags: ${{ steps.meta.outputs.tags }}
        labels: ${{ steps.meta.outputs.labels }}

Logs

Raw Logs
Logs Archive

Add appending option to tags

Let's say you build multiple distro flavors of your Docker image, e. g. one in Ubuntu (main) and one in Alpine.
Meanwhile it's fine to use the usual tagging for the main image, is there a way of setting a "base tag" or a "tag" to be appended? In this case, for the Alpine flavor, instead of latest, using alpine, x.x.x-alpine etc. is more appropriate.

Proposal: Redesign tagging input/outputs to be independent

I still use this action for labeling features, but if you're open to it, I'd really like you to consider importing my actions tag handling capabilities due to their power, simplicity, and flexibility.

To give you an example, here's a snippet from a repo where I'm using the latest functionality I've implemented, snippet pulled from https://github.com/OctoPrint/octoprint-docker/blob/master/.github/workflows/octoprint-release.yml#L69-L87:

      -
        id: buildxy
        run: echo '::set-output name=buildxy::${{ (github.event.action == 'deploy'|| github.event.action == 'released') && github.event.client_payload.tag_name == steps.stable-octoprint.outputs.release }}'
      -
        name: Tagging Strategy
        id: tagging
        uses: HackerHappyHour/tagging-strategy@v3
        with:
          image_name: octoprint/octoprint
          tag_name: ${{ github.event.client_payload.tag_name }}
          tags: |
            %X%::${{ steps.buildxy.outputs.buildxy }}
            %X.Y%::${{ steps.buildxy.outputs.buildxy }}
            %X.Y.Z%
          extra_tags: |
            latest::${{ steps.stable-octoprint.outputs.release == github.event.client_payload.tag_name }}
            edge::${{ github.event.action == 'prereleased' || github.event.client_payload.tag_name == steps.latest-octoprint.outputs.release }}
            canary::${{ github.event.action == 'canary' }}
            bleeding::${{ github.event.action == 'bleeding' }}

This one snippet demonstrates the how i think the approach to tagging should work in ghaction-dockermeta:

  • explicit control over the conditions of each and every tag,
  • semver parsing
  • no interdependent input parameters,
  • output compatible with docker/build-push-action
  • supports tag suffixes #15
  • supports additional non-semver custom tags #24 via extra_tags
  • compatible with externally triggered events
  • sha tags (via extra_tags parameter in a similar way to your {{raw}} usage

Bonus

As far as I can tell, refactoring tag inputs to work as they do in HackerHappyHour/tagging-strategy@v3+ would close the following open issues as well:

  • #29 (since the base tag input isn't resolved by the action but passed in by the user, the user can pass in whatever they want)
  • #27 (simply changing the order in the tags or extra_tags of HackerHappyHour/tagging-strategy accomplishes this)
  • #25 (you can see in the example above how HackerHappyHour/tagging-strategy already does this)
  • #13 (HackerHappyHour/tagging-strategy already supports this, examples here, here and in the testing fixtures)

I doubt my action will ever get any users (even though I obviously have a super high opinion of it ๐Ÿ˜ ), but you've got the benefit of having been in the docker action space since actions launched, and the have visibility and reach. I'd love for the work I did to benefit your users and carry over here.

Would you be willing to consider a redesign to bring support for this usage technique? I'd really love to be able to archive my project and merge it with yours!

Convert repo name to lower case.

-
        name: Docker meta
        id: docker_meta
        uses: crazy-max/ghaction-docker-meta@v1
        with:
          images: ${{ github.repository }}

and when the repo name container upper case it fails to push. It would be nice to convert it all to lower case

Should tag-semver work without patch version?

Some small projects might decide not to release patch versions but still follow the semantic versioning rules. Can this action work with tag-semver: v${{major}} on tags like v1.0 to produce v1? Currently, it does not seem to:

https://github.com/EnricoMi/publish-unit-test-result-action/runs/1474478085?check_suite_focus=true

Run crazy-max/ghaction-docker-meta@v1
  with:
    images: ghcr.io/EnricoMi/publish-unit-test-result-action
    tag-sha: true
    tag-semver: {{raw}}
  v{{major}}.{{minor}}
  v{{major}}
  
    tag-edge: false
    tag-match-group: 0
    tag-match-latest: true
    tag-schedule: nightly
    github-token: ***
Context info
Docker image version
  v1.6
Docker tags
  ghcr.io/enricomi/publish-unit-test-result-action:v1.6
  ghcr.io/enricomi/publish-unit-test-result-action:latest
  ghcr.io/enricomi/publish-unit-test-result-action:sha-f1387c5

No support for Python packages versioning (PEP 440)

Hi!

Thanks for the cool action! It works like a charm ...as long as you are using semver.

Unfortunately in my case I wanted to use it for a Python package, which is versioned according to a pythonic standard - PEP440 - which is not semver-compatible.

I couldn't just use type=match as in the case of the pre-release versions we should not add any other tags than the one with just the version itself.

Initially I wanted to create a PR to add support for PEP 440 to this project, but I don't really know Typescript, so I ended up with writing it in, well, Python.

I would like to share this solution here for other people with such problem to find it and use this as a workaround and/or for someone to consider rewriting this in Typescript and making that PR. :)

Anyway: happy hacking!

name: publish ๐Ÿณ Docker image

on:
  push:
    tags:
      - "v*"

jobs:

  build-and-push-image:

    runs-on: ubuntu-latest

    permissions:
      contents: read
      packages: write

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v1
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Get tags
        shell: python
        run: |
          import re
          from packaging.version import parse

          version = "${{ github.ref }}".replace("refs/tags/v", "")
          image = "ghcr.io/${{ github.repository }}"

          tags = set()

          # full version
          tags.add(f"{image}:{version}")

          if not parse(version).is_prerelease:
              # only final and post-releases should get the tags
              # used for automatic use of latest *stable* version

              # major_version
              major_version = re.search(r'(\d+?)\.', version).group(1)
              tags.add(f"{image}:{major_version}")

              # major_version.minor_version
              major_and_minor_version = re.search(r'(\d+?\.\d+?)\.', version).group(1)
              tags.add(f"{image}:{major_and_minor_version}")

              tags.add(f"{image}:latest")

          tags = ",".join(sorted(list(tags)))

          print(f"::set-output name=tags::{tags}")

        id: tags

      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          context: .
          platforms: linux/amd64
          push: true
          tags: ${{ steps.tags.outputs.tags }}

(source: voxpupuli/puppetboard@924bb55 + voxpupuli/puppetboard@94052a0)

pull_request_target triggers the event=branch when it should only trigger on event=pr

@crazy-max -- I'm still getting a tag for the base branch (IE localhost:5000/run-drc-for-cell-gds-using-magic:main) - Have I configured things wrong or is pull_request_target getting misunderstood as being a branch/tag event as well as a pull request event? Output below;

  with:
    images: localhost:5000/run-drc-for-cell-gds-using-magic,gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic
    tags: type=ref,event=tag
  type=ref,event=pr
  type=ref,event=branch
  type=sha
  type=sha,format=long
  
    github-token: ***
  env:
    ACTION_NAME: run-drc-for-cell-gds-using-magic
Context info
  eventName: pull_request_target
  sha: 1791415f66d16e92bdc523c59e68383db3b32d74
  ref: refs/heads/main
  workflow: Build Docker Image for Run DRC for cell GDS (using Magic) Action
  action: dockermetadata-action
  actor: mithro
  runNumber: 22
  runId: 875362048
Processing tags input
Processing flavor input
Docker image version
  pr-21
Docker tags
  localhost:5000/run-drc-for-cell-gds-using-magic:pr-21
  localhost:5000/run-drc-for-cell-gds-using-magic:main
  localhost:5000/run-drc-for-cell-gds-using-magic:sha-1791415
  localhost:5000/run-drc-for-cell-gds-using-magic:sha-1791415f66d16e92bdc523c59e68383db3b32d74
  gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:pr-21
  gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:main
  gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:sha-1791415
  gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:sha-1791415f66d16e92bdc523c59e68383db3b32d74

Originally posted by @mithro in #90 (comment)

Handle branch names including issue numbers correctly

Behaviour

When using this action with branches that include issue numbers with hash signs then the tag values are generated including the hash sign. Since those are not valid tag names the further processing fails when you try to tag an image.

Steps to reproduce this issue

  1. use this action with a branch including a hash sign in its name
  2. try to build/tag the image

Expected behaviour

Replace hash sign with a dash or something else just like it happens for slashes.

Logs

Logs here
2020-12-05T14:55:41.9591861Z ##[section]Starting: Request a runner to run this job
2020-12-05T14:55:42.5631247Z Can't find any online and idle self-hosted runner in current repository that matches the required labels: 'ubuntu-latest'
2020-12-05T14:55:42.5631555Z Can't find any online and idle self-hosted runner in current repository's account/organization that matches the required labels: 'ubuntu-latest'
2020-12-05T14:55:42.5631906Z Found online and idle hosted runner in current repository's account/organization that matches the required labels: 'ubuntu-latest'
2020-12-05T14:55:42.7639461Z ##[section]Finishing: Request a runner to run this job
2020-12-05T14:55:51.7446658Z Current runner version: '2.274.2'
2020-12-05T14:55:51.7482226Z ##[group]Operating System
2020-12-05T14:55:51.7483156Z Ubuntu
2020-12-05T14:55:51.7483604Z 18.04.5
2020-12-05T14:55:51.7483990Z LTS
2020-12-05T14:55:51.7484418Z ##[endgroup]
2020-12-05T14:55:51.7485078Z ##[group]Virtual Environment
2020-12-05T14:55:51.7486126Z Environment: ubuntu-18.04
2020-12-05T14:55:51.7486702Z Version: 20201129.1
2020-12-05T14:55:51.7487701Z Included Software: https://github.com/actions/virtual-environments/blob/ubuntu18/20201129.1/images/linux/Ubuntu1804-README.md
2020-12-05T14:55:51.7488743Z ##[endgroup]
2020-12-05T14:55:51.7492482Z Prepare workflow directory
2020-12-05T14:55:51.8170632Z Prepare all required actions
2020-12-05T14:55:51.8182592Z Getting action download info
2020-12-05T14:55:52.1582860Z Download action repository 'actions/checkout@v2'
2020-12-05T14:55:55.3407651Z Download action repository 'docker/setup-buildx-action@v1'
2020-12-05T14:55:56.9234187Z Download action repository 'crazy-max/ghaction-docker-meta@v1'
2020-12-05T14:55:58.6776711Z Download action repository 'actions/cache@v2'
2020-12-05T14:56:00.6388950Z Download action repository 'docker/login-action@v1'
2020-12-05T14:56:02.5685405Z Download action repository 'docker/build-push-action@v2'
2020-12-05T14:56:04.8856443Z ##[group]Run actions/checkout@v2
2020-12-05T14:56:04.8857069Z with:
2020-12-05T14:56:04.8858428Z   repository: Gruppe-1-SE-WS21/SoftwareEngineering-WS2021-Gruppe1
2020-12-05T14:56:04.8860176Z   token: ***
2020-12-05T14:56:04.8860949Z   ssh-strict: true
2020-12-05T14:56:04.8861694Z   persist-credentials: true
2020-12-05T14:56:04.8862197Z   clean: true
2020-12-05T14:56:04.8862590Z   fetch-depth: 1
2020-12-05T14:56:04.8862987Z   lfs: false
2020-12-05T14:56:04.8863367Z   submodules: false
2020-12-05T14:56:04.8863915Z ##[endgroup]
2020-12-05T14:56:05.3118741Z Syncing repository: Gruppe-1-SE-WS21/SoftwareEngineering-WS2021-Gruppe1
2020-12-05T14:56:05.3119841Z ##[group]Getting Git version info
2020-12-05T14:56:05.3121342Z Working directory is '/home/runner/work/SoftwareEngineering-WS2021-Gruppe1/SoftwareEngineering-WS2021-Gruppe1'
2020-12-05T14:56:05.3183878Z [command]/usr/bin/git version
2020-12-05T14:56:05.3355205Z git version 2.29.2
2020-12-05T14:56:05.3381330Z ##[endgroup]
2020-12-05T14:56:05.3394611Z Deleting the contents of '/home/runner/work/SoftwareEngineering-WS2021-Gruppe1/SoftwareEngineering-WS2021-Gruppe1'
2020-12-05T14:56:05.3397089Z ##[group]Initializing the repository
2020-12-05T14:56:05.3402389Z [command]/usr/bin/git init /home/runner/work/SoftwareEngineering-WS2021-Gruppe1/SoftwareEngineering-WS2021-Gruppe1
2020-12-05T14:56:05.3502295Z Initialized empty Git repository in /home/runner/work/SoftwareEngineering-WS2021-Gruppe1/SoftwareEngineering-WS2021-Gruppe1/.git/
2020-12-05T14:56:05.3518548Z [command]/usr/bin/git remote add origin https://github.com/Gruppe-1-SE-WS21/SoftwareEngineering-WS2021-Gruppe1
2020-12-05T14:56:05.3568887Z ##[endgroup]
2020-12-05T14:56:05.3570827Z ##[group]Disabling automatic garbage collection
2020-12-05T14:56:05.3571833Z [command]/usr/bin/git config --local gc.auto 0
2020-12-05T14:56:05.3622327Z ##[endgroup]
2020-12-05T14:56:05.3625085Z ##[group]Setting up auth
2020-12-05T14:56:05.3626246Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2020-12-05T14:56:05.3660680Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2020-12-05T14:56:05.4106215Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2020-12-05T14:56:05.4173166Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :
2020-12-05T14:56:05.4436307Z [command]/usr/bin/git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***
2020-12-05T14:56:05.4495085Z ##[endgroup]
2020-12-05T14:56:05.4496568Z ##[group]Fetching the repository
2020-12-05T14:56:05.4506426Z [command]/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +a360c24101763da049cf68ada5731c19242c8c20:refs/remotes/origin/feature/#6-skillquiz
2020-12-05T14:56:06.1674797Z remote: Enumerating objects: 136, done.        
2020-12-05T14:56:06.1677609Z remote: Counting objects:   0% (1/136)        
2020-12-05T14:56:06.1689401Z remote: Counting objects:   1% (2/136)        
2020-12-05T14:56:06.1690022Z remote: Counting objects:   2% (3/136)        
...
2020-12-05T14:56:06.2153876Z remote: Counting objects:  98% (134/136)        
2020-12-05T14:56:06.2154321Z remote: Counting objects:  99% (135/136)        
2020-12-05T14:56:06.2154771Z remote: Counting objects: 100% (136/136)        
2020-12-05T14:56:06.2155241Z remote: Counting objects: 100% (136/136), done.        
2020-12-05T14:56:06.2156040Z remote: Compressing objects:   0% (1/120)        
2020-12-05T14:56:06.2156552Z remote: Compressing objects:   1% (2/120)        
....
2020-12-05T14:56:06.2207047Z remote: Compressing objects:  98% (118/120)        
2020-12-05T14:56:06.2207771Z remote: Compressing objects:  99% (119/120)        
2020-12-05T14:56:06.2208717Z remote: Compressing objects: 100% (120/120)        
2020-12-05T14:56:06.2209303Z remote: Compressing objects: 100% (120/120), done.        
2020-12-05T14:56:06.2321971Z Receiving objects:   0% (1/136)
2020-12-05T14:56:06.2322986Z Receiving objects:   1% (2/136)
2020-12-05T14:56:06.2323674Z Receiving objects:   2% (3/136)
....
2020-12-05T14:56:07.0171968Z Receiving objects:  98% (134/136), 6.45 MiB | 12.89 MiB/s
2020-12-05T14:56:07.0172571Z Receiving objects:  99% (135/136), 6.45 MiB | 12.89 MiB/s
2020-12-05T14:56:07.0173087Z Receiving objects: 100% (136/136), 6.45 MiB | 12.89 MiB/s
2020-12-05T14:56:07.0173738Z Receiving objects: 100% (136/136), 16.54 MiB | 21.12 MiB/s, done.
2020-12-05T14:56:07.0174644Z Resolving deltas:   0% (0/8)
2020-12-05T14:56:07.0175401Z Resolving deltas:  12% (1/8)
2020-12-05T14:56:07.0175946Z Resolving deltas:  25% (2/8)
2020-12-05T14:56:07.0176498Z Resolving deltas:  37% (3/8)
2020-12-05T14:56:07.0177093Z Resolving deltas:  50% (4/8)
2020-12-05T14:56:07.0177683Z Resolving deltas:  62% (5/8)
2020-12-05T14:56:07.0182550Z Resolving deltas:  75% (6/8)
2020-12-05T14:56:07.0197359Z Resolving deltas:  87% (7/8)
2020-12-05T14:56:07.0198417Z Resolving deltas: 100% (8/8)
2020-12-05T14:56:07.0199188Z Resolving deltas: 100% (8/8), done.
2020-12-05T14:56:07.2623477Z From https://github.com/Gruppe-1-SE-WS21/SoftwareEngineering-WS2021-Gruppe1
2020-12-05T14:56:07.2625307Z  * [new ref]         a360c24101763da049cf68ada5731c19242c8c20 -> origin/feature/#6-skillquiz
2020-12-05T14:56:07.2653797Z ##[endgroup]
2020-12-05T14:56:07.2656401Z ##[group]Determining the checkout info
2020-12-05T14:56:07.2659002Z ##[endgroup]
2020-12-05T14:56:07.2661860Z ##[group]Checking out the ref
2020-12-05T14:56:07.2665986Z [command]/usr/bin/git checkout --progress --force -B feature/#6-skillquiz refs/remotes/origin/feature/#6-skillquiz
2020-12-05T14:56:07.4147785Z Switched to a new branch 'feature/#6-skillquiz'
2020-12-05T14:56:07.4151180Z Branch 'feature/#6-skillquiz' set up to track remote branch 'feature/#6-skillquiz' from 'origin'.
2020-12-05T14:56:07.4162870Z ##[endgroup]
2020-12-05T14:56:07.4229274Z [command]/usr/bin/git log -1 --format='%H'
2020-12-05T14:56:07.4262815Z 'a360c24101763da049cf68ada5731c19242c8c20'
2020-12-05T14:56:07.4424938Z ##[group]Run docker/setup-buildx-action@v1
2020-12-05T14:56:07.4425399Z with:
2020-12-05T14:56:07.4425768Z   driver: docker-container
2020-12-05T14:56:07.4426685Z   buildkitd-flags: --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host
2020-12-05T14:56:07.4427580Z   install: false
2020-12-05T14:56:07.4427941Z   use: true
2020-12-05T14:56:07.4428247Z ##[endgroup]
2020-12-05T14:56:09.0470020Z ๐Ÿ“ฃ Buildx version: 0.4.2
2020-12-05T14:56:09.3364761Z ##[group]๐Ÿ”จ Creating a new builder instance
2020-12-05T14:56:09.3418865Z [command]/usr/bin/docker buildx create --name builder-build-2 --driver docker-container --driver-opt image=moby/buildkit:v0.8-beta --buildkitd-flags --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host --use
2020-12-05T14:56:09.4598324Z builder-build-2
2020-12-05T14:56:09.4636512Z ##[endgroup]
2020-12-05T14:56:09.4645205Z ##[group]๐Ÿƒ Booting builder
2020-12-05T14:56:09.4740388Z [command]/usr/bin/docker buildx inspect --bootstrap
2020-12-05T14:56:09.5579688Z #1 [internal] booting buildkit
2020-12-05T14:56:09.7177264Z #1 pulling image moby/buildkit:v0.8-beta
2020-12-05T14:56:13.3099556Z #1 pulling image moby/buildkit:v0.8-beta 3.8s done
2020-12-05T14:56:13.4597282Z #1 creating container buildx_buildkit_builder-build-20
2020-12-05T14:56:15.9010829Z #1 creating container buildx_buildkit_builder-build-20 2.6s done
2020-12-05T14:56:15.9011542Z #1 DONE 6.3s
2020-12-05T14:56:16.0406864Z Name:   builder-build-2
2020-12-05T14:56:16.0432877Z Driver: docker-container
2020-12-05T14:56:16.0434533Z 
2020-12-05T14:56:16.0434932Z Nodes:
2020-12-05T14:56:16.0435741Z Name:      builder-build-20
2020-12-05T14:56:16.0453786Z Endpoint:  unix:///var/run/docker.sock
2020-12-05T14:56:16.0454393Z Status:    running
2020-12-05T14:56:16.0455818Z Flags:     --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host
2020-12-05T14:56:16.0456824Z Platforms: linux/amd64, linux/386
2020-12-05T14:56:16.0457713Z ##[endgroup]
2020-12-05T14:56:16.0458777Z ##[group]๐Ÿ›’ Extracting available platforms
2020-12-05T14:56:16.2705293Z linux/amd64,linux/386
2020-12-05T14:56:16.2708313Z ##[endgroup]
2020-12-05T14:56:16.2891859Z ##[group]Run crazy-max/ghaction-docker-meta@v1
2020-12-05T14:56:16.2892694Z with:
2020-12-05T14:56:16.2893623Z   images: Gruppe-1-SE-WS21/SoftwareEngineering-WS2021-Gruppe1/skillmanagement-web
2020-12-05T14:56:16.2894576Z   tag-sha: true
2020-12-05T14:56:16.2895422Z   tag-edge: false
2020-12-05T14:56:16.2895838Z   tag-match-group: 0
2020-12-05T14:56:16.2896400Z   tag-latest: true
2020-12-05T14:56:16.2896807Z   tag-match-latest: true
2020-12-05T14:56:16.2897287Z   tag-schedule: nightly
2020-12-05T14:56:16.2898041Z   github-token: ***
2020-12-05T14:56:16.2898793Z ##[endgroup]
2020-12-05T14:56:17.2697042Z ##[group]Context info
2020-12-05T14:56:17.2697558Z eventName: workflow_dispatch
2020-12-05T14:56:17.2698131Z sha: a360c24101763da049cf68ada5731c19242c8c20
2020-12-05T14:56:17.2699403Z ref: refs/heads/feature/#6-skillquiz
2020-12-05T14:56:17.2700104Z workflow: skillmanagement-web-build
2020-12-05T14:56:17.2701902Z action: crazy-maxghaction-docker-meta
2020-12-05T14:56:17.2702726Z actor: whymatter
2020-12-05T14:56:17.2703101Z runNumber: 4
2020-12-05T14:56:17.2703408Z runId: 402669340
2020-12-05T14:56:17.2703880Z ##[endgroup]
2020-12-05T14:56:17.2705499Z ##[group]Docker image version
2020-12-05T14:56:17.2706573Z feature-#6-skillquiz
2020-12-05T14:56:17.2707091Z ##[endgroup]
2020-12-05T14:56:17.2739130Z ##[group]Docker tags
2020-12-05T14:56:17.2740377Z gruppe-1-se-ws21/softwareengineering-ws2021-gruppe1/skillmanagement-web:feature-#6-skillquiz
2020-12-05T14:56:17.2742305Z gruppe-1-se-ws21/softwareengineering-ws2021-gruppe1/skillmanagement-web:sha-a360c24
2020-12-05T14:56:17.2743233Z ##[endgroup]
2020-12-05T14:56:17.2745149Z ##[group]Docker labels
2020-12-05T14:56:17.2746238Z org.opencontainers.image.title=SoftwareEngineering-WS2021-Gruppe1
2020-12-05T14:56:17.2747350Z org.opencontainers.image.description=Gruppe 1 SE WS2021
2020-12-05T14:56:17.2748777Z org.opencontainers.image.url=https://github.com/Gruppe-1-SE-WS21/SoftwareEngineering-WS2021-Gruppe1
2020-12-05T14:56:17.2750564Z org.opencontainers.image.source=https://github.com/Gruppe-1-SE-WS21/SoftwareEngineering-WS2021-Gruppe1
2020-12-05T14:56:17.2751979Z org.opencontainers.image.version=feature-#6-skillquiz
2020-12-05T14:56:17.2753039Z org.opencontainers.image.created=2020-12-05T14:56:17.269Z
2020-12-05T14:56:17.2753964Z org.opencontainers.image.revision=a360c24101763da049cf68ada5731c19242c8c20
2020-12-05T14:56:17.2754890Z org.opencontainers.image.licenses=
2020-12-05T14:56:17.2755460Z ##[endgroup]
2020-12-05T14:56:17.2930284Z ##[group]Run actions/cache@v2
2020-12-05T14:56:17.2930882Z with:
2020-12-05T14:56:17.2931233Z   path: /tmp/.buildx-cache
2020-12-05T14:56:17.2932579Z   key: Linux-buildx-a360c24101763da049cf68ada5731c19242c8c20
2020-12-05T14:56:17.2933442Z   restore-keys: Linux-buildx-

2020-12-05T14:56:17.2934038Z ##[endgroup]
2020-12-05T14:56:18.0770498Z Cache not found for input keys: Linux-buildx-a360c24101763da049cf68ada5731c19242c8c20, Linux-buildx-
2020-12-05T14:56:18.0905625Z ##[group]Run docker/login-action@v1
2020-12-05T14:56:18.0906276Z with:
2020-12-05T14:56:18.0906641Z   registry: ghcr.io
2020-12-05T14:56:18.0907086Z   username: whymatter
2020-12-05T14:56:18.0908142Z   password: ***
2020-12-05T14:56:18.0908491Z   logout: true
2020-12-05T14:56:18.0908819Z ##[endgroup]
2020-12-05T14:56:18.1377370Z ๐Ÿ”‘ Logging into ghcr.io...
2020-12-05T14:56:19.1062368Z ๐ŸŽ‰ Login Succeeded!
2020-12-05T14:56:19.1245938Z ##[group]Run docker/build-push-action@v2
2020-12-05T14:56:19.1246407Z with:
2020-12-05T14:56:19.1246802Z   context: ./skillmanagement/web
2020-12-05T14:56:19.1247299Z   file: ./build/Dockerfile
2020-12-05T14:56:19.1248886Z   tags: gruppe-1-se-ws21/softwareengineering-ws2021-gruppe1/skillmanagement-web:feature-#6-skillquiz
gruppe-1-se-ws21/softwareengineering-ws2021-gruppe1/skillmanagement-web:sha-a360c24
2020-12-05T14:56:19.1254544Z   labels: org.opencontainers.image.title=SoftwareEngineering-WS2021-Gruppe1
org.opencontainers.image.description=Gruppe 1 SE WS2021
org.opencontainers.image.url=https://github.com/Gruppe-1-SE-WS21/SoftwareEngineering-WS2021-Gruppe1
org.opencontainers.image.source=https://github.com/Gruppe-1-SE-WS21/SoftwareEngineering-WS2021-Gruppe1
org.opencontainers.image.version=feature-#6-skillquiz
org.opencontainers.image.created=2020-12-05T14:56:17.269Z
org.opencontainers.image.revision=a360c24101763da049cf68ada5731c19242c8c20
org.opencontainers.image.licenses=
2020-12-05T14:56:19.1259582Z   push: true
2020-12-05T14:56:19.1260050Z   cache-from: type=local,src=/tmp/.buildx-cache
2020-12-05T14:56:19.1260672Z   cache-to: type=local,dest=/tmp/.buildx-cache
2020-12-05T14:56:19.1261867Z   pull: false
2020-12-05T14:56:19.1262237Z   no-cache: false
2020-12-05T14:56:19.1262552Z   load: false
2020-12-05T14:56:19.1263549Z   github-token: ***
2020-12-05T14:56:19.1263912Z ##[endgroup]
2020-12-05T14:56:19.4033108Z ๐Ÿ“ฃ Buildx version: 0.4.2
2020-12-05T14:56:19.4088758Z ๐Ÿƒ Starting build...
2020-12-05T14:56:19.4126951Z [command]/usr/bin/docker buildx build --label org.opencontainers.image.title=SoftwareEngineering-WS2021-Gruppe1 --label org.opencontainers.image.description=Gruppe 1 SE WS2021 --label org.opencontainers.image.url=https://github.com/Gruppe-1-SE-WS21/SoftwareEngineering-WS2021-Gruppe1 --label org.opencontainers.image.source=https://github.com/Gruppe-1-SE-WS21/SoftwareEngineering-WS2021-Gruppe1 --label org.opencontainers.image.version=feature-#6-skillquiz --label org.opencontainers.image.created=2020-12-05T14:56:17.269Z --label org.opencontainers.image.revision=a360c24101763da049cf68ada5731c19242c8c20 --label org.opencontainers.image.licenses= --tag gruppe-1-se-ws21/softwareengineering-ws2021-gruppe1/skillmanagement-web:feature-#6-skillquiz --tag gruppe-1-se-ws21/softwareengineering-ws2021-gruppe1/skillmanagement-web:sha-a360c24 --iidfile /tmp/docker-build-push-PdRQy5/iidfile --cache-from type=local,src=/tmp/.buildx-cache --cache-to type=local,dest=/tmp/.buildx-cache --file ./build/Dockerfile --push ./skillmanagement/web
2020-12-05T14:56:19.5046482Z time="2020-12-05T14:56:19Z" level=warning msg="invalid non-bool value for BUILDX_NO_DEFAULT_LOAD: "
2020-12-05T14:56:19.5072209Z invalid tag "gruppe-1-se-ws21/softwareengineering-ws2021-gruppe1/skillmanagement-web:feature-#6-skillquiz": invalid reference format
2020-12-05T14:56:19.5219242Z ##[error]buildx call failed with: invalid tag "gruppe-1-se-ws21/softwareengineering-ws2021-gruppe1/skillmanagement-web:feature-#6-skillquiz": invalid reference format
2020-12-05T14:56:19.5357187Z Post job cleanup.
2020-12-05T14:56:19.6256585Z ๐Ÿšฟ Removing temp folder /tmp/docker-build-push-PdRQy5
2020-12-05T14:56:19.6405926Z Post job cleanup.
2020-12-05T14:56:19.6980864Z [command]/usr/bin/docker logout ghcr.io
2020-12-05T14:56:19.7426134Z Removing login credentials for ghcr.io
2020-12-05T14:56:19.7568626Z Post job cleanup.
2020-12-05T14:56:19.8201428Z [command]/usr/bin/docker buildx rm builder-build-2
2020-12-05T14:56:20.1722934Z Post job cleanup.
2020-12-05T14:56:20.2875772Z [command]/usr/bin/git version
2020-12-05T14:56:20.2956681Z git version 2.29.2
2020-12-05T14:56:20.2996404Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2020-12-05T14:56:20.3032810Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2020-12-05T14:56:20.3369643Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2020-12-05T14:56:20.3400391Z http.https://github.com/.extraheader
2020-12-05T14:56:20.3410951Z [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
2020-12-05T14:56:20.3462114Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :
2020-12-05T14:56:20.3814916Z Cleaning up orphan processes

prefix/suffix not working?

Behaviour

I am unable to add a prefix or suffix in v2 of this action, regardless if specified in the flavor or in the tag attributes.

Steps to reproduce this issue

  1. Specify suffix=-dev in flavor or individual tag
  2. Run action
  3. Suffix is not applied

Expected behaviour

The action should append the suffix to the tag

Actual behaviour

The suffix is not appended

Configuration

- name: Set -dev suffix
  id: release_type
  run: |
    if [[ ${{ contains(github.event.release.tag_name, '-dev') }} = true ]]
    then
      echo '::set-output name=dev-suffix::-dev'
    else
      echo '::set-output name=dev-suffix::'
    fi

- name: Docker meta
  id: docker_meta
  uses: crazy-max/ghaction-docker-meta@v2
  with:
    images: strophy/drive
    tags: |
      type=match,pattern=v(\d+),group=1
      type=match,pattern=v(\d+.\d+),group=1
      type=match,pattern=v(\d+.\d+.\d+),group=1
      type=match,pattern=v(.*),group=1,suffix=,enable=${{ contains(github.event.release.tag_name, '-dev') }}
    flavor: |
      latest=${{ !contains(github.event.release.tag_name, '-dev') }}
      suffix=${{ steps.release_type.outputs.dev-suffix }}

Logs

logs_396.zip

Monorepo usage?

Would it be possible to use this with a monorepo of docker images? If so how?

Tag images from PR with branch?

Behaviour

Expected behaviour

When pushing to a PR branch, I expect to have a devops-comedy:<branch> and devops-comedy:pr-<number> tag generated - among others.

Actual behaviour

The devops-comedy:<branch> tag is not generated, and the two SHA tags that should be prefixed with the branch name are not.

Configuration

  • Repository URL (if public):
  • Build URL (if public):
name: devops-comedy

on:
  pull_request:

  push:
    branches:
      - master

jobs:
  build:
    runs-on: self-hosted
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Generate container metadata
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: <my_repo>/devops-comedy
          tags: |
            type=ref,event=branch
            type=ref,event=pr
            type=ref,event=tag
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}
            type=sha
            type=sha,prefix={{branch}}-
            type=sha,format=long
            type=sha,format=long,prefix={{branch}}-

      - name: Setup Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Login to MLB Artifactory
        uses: docker/login-action@v1
        with:
          registry: <mlb_registry>
          username: ${{ secrets.MLB_ARTIFACTORY_USERNAME }}
          password: ${{ secrets.MLB_ARTIFACTORY_PASSWORD }}

      - name: Build & push container image
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          cache-from: type=registry,ref=<my_repo>/devops-comedy:latest
          cache-to: type=inline
          context: .
          labels: ${{ steps.meta.outputs.labels }}
          push: true
          tags: ${{ steps.meta.outputs.tags }}

      - name: Output container image digest
        run: echo ${{ steps.docker_build.outputs.digest }}

Logs

logs_7.zip

Should 'latest' be given it's own input as a 'boolen'?

The generation of latest seems somewhat problematic. There no way to directly prevent latest from being generated in many cases,

Would it be better, easier, and more straightforware to remove the latest generation logic entirely the way it is now, and just make it a boolean input type so that users could specify whether or not to generate the latest explicitly regardless of the event?

Question: list vs YAML array for inputs

Hello!
I was wondering why use multi-line string list instead of YAML array for inputs?
Maybe it's a technical limitation and it's okay if so I just wanted to check.

I'm trying to pass build args to the docker build with meta information and having difficulties because of this list type.
https://github.com/docker/metadata-action provides an easy way to inject meta labels for the container,
exporting a list of OCI labels that you can then use for labels: input. I guess they used a list type for their output to match this action input type.

I'm trying to reuse some of them as build args to also inject this information into the app binary, but it doesn't work because steps.meta.outputs.labels is not an array. I was looking around for a conversion function or tool that would help me to get this values out of labels, but couldn't find anything.

      - name: Prepare image metadata
        uses: docker/metadata-action@v3
        id: meta
        with:
          images: repo/app

      - name: Build and push docker image
        uses: docker/build-push-action@v2
        with:
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          build-args: |
            BUILDTIME=${{ steps.meta.outputs.labels['org.opencontainers.image.created'] }}
            VERSION=${{ steps.meta.outputs.labels['org.opencontainers.image.version'] }}
            REVISION=${{ steps.meta.outputs.labels['org.opencontainers.image.revision'] }}

I think it would be more convenient to work with JSON/YAML Arrays, just because there's a lot more supported tooling and operations than for just a list of strings.

Curious to get your opinion on this

Tag chaining with match and semver

Behaviour

My context is kind of mono repository that each project has itself life-cycle.
Currently, I separate GitHub release tag as: project/semver

Steps to reproduce this issue

  1. Input
# Ref context
refs/tags/project1/v1.0.0
# GH docker meta
tags: type=ref,event=branch
  type=ref,event=tag
  type=ref,event=pr
  type=sha
  type=match,pattern=project1\/v(.*),group=1
  1. Output
project1-v1.0.0

It should be 1.0.0 ???

Expected behaviour

I'm wondering how to make tag chaining from match to semver. I have not yet understand prefix/suffix/value for what purpose.
In my case: I expect tag output is

  • 1.0.0
  • 1.0
  • latest

Another thing, typo in https://github.com/crazy-max/ghaction-docker-meta#typematch

tags: |
  type=group,enable=true,priority=800,prefix=,suffix=,pattern=,group=0,value=

Should be type=match?

Description and license label source?

Where does it pull from to fill the oci labels for description and license? Mine are blank though I do not have a license.md file in my repo (my 1st guess for license?).

Double quotes in repository description causes downstream build-push-action error

Behaviour

Steps to reproduce this issue

  • In the repository description, use some double quotes.
  • Run docker/metadata-action@v3
  • ...followed by docker/build-push-action@v2 with labels: ${{ steps.meta.outputs.labels }}

Expected behaviour

I hoped that this would run without errors and push a docker image.

Actual behaviour

docker/build-push-action fails with
Error: Invalid Opening Quote: a quote is found inside a field at line 2

Configuration

name: 'release'

on:
    release:
        types: [published]

jobs:
    push_to_registry:
        name: Push Docker image to GitHub Packages tagged with "latest" and version number.
        runs-on: ubuntu-latest
        permissions: 
            contents: read
            packages: write
        steps:
            - name: Checkout
              uses: actions/checkout@v2

            - name: Docker meta
              id: meta
              uses: docker/metadata-action@v3
              with:
                # list of Docker images to use as base name for tags
                images: |
                  ghcr.io/TranslatorSRI/filter_results_top_n
                # add latest tag when appropriate
                flavor: |
                  latest=auto
                # generate Docker tags based on the following events/attributes
                tags: |
                  type=semver,pattern={{version}}
                  type=semver,pattern={{major}}.{{minor}}
                  type=semver,pattern={{major}}
                  type=sha

            - name: Set up QEMU
              uses: docker/setup-qemu-action@v1

            - name: Set up Docker Buildx
              uses: docker/setup-buildx-action@v1

            - name: Login to GHCR
              uses: docker/login-action@v1
              with:
                registry: ghcr.io
                username: ${{ github.repository_owner }}
                password: ${{ secrets.GITHUB_TOKEN }}

            - name: Build and push
              uses: docker/build-push-action@v2
              with:
                context: .
                push: true
                tags: ${{ steps.meta.outputs.tags }}
                labels: ${{ steps.meta.outputs.labels }}

Logs

logs_7.zip

Notes

A workaround is simply to avoid double quotes in the repository description.

A potential solution is to escape the quotes in the labels by doubling them: docker/build-push-action#245 (comment), but this may not be kind to other uses of the metadata output.

Feature request: add branch-tag-latest

For my repo I'd like to mark new image as latest for every build off the main branch. It'd be nice to have branch-tag-latest together with branch-tag which would add latest tag if github.ref would match the specified pattern.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.