docker / metadata-action

GitHub Action to extract metadata (tags, labels) from Git reference and GitHub events for Docker
https://github.com/marketplace/actions/docker-metadata-action
Apache License 2.0
901 stars 117 forks source link

Proposal to add an input to allow fail on warnings #200

Open CAMOBAP opened 2 years ago

CAMOBAP commented 2 years ago

Behaviour

Steps to reproduce this issue

  1. pass version which is a not valid semver.org version
  2. the action will warn you will message like Warning: v1.5.15pre1 is not a valid semver. More info: https://semver.org/

Expected behavior

It will be nice to add some strict input to treat all warnings as errors. And if the version is invalid the docker/metadata-action step will fails

Actual behaviour

I suppose current behavior is right


This ticket just to understand if this feature is useful for someone else

crazy-max commented 2 years ago

@CAMOBAP You have this warning because you're using type=semver: https://github.com/metanorma/metanorma-docker/blob/abc2919a7793838262a48697931b4e267c3a56f0/.github/workflows/build-push.yml#L78-L84

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

If your tag doesn't support semver and you just want the tag, then just replace type=semver with:

        tags: |
          type=edge,branch=main
          type=ref,event=branch
          type=ref,event=pr
          type=ref,event=tag
CAMOBAP commented 2 years ago

@crazy-max thanks for the suggestion. The problem is solved actually, my point is that this warning is silent, you can find it only if other steps fail. Isn't it better if the step will fail instead of the warning message?

crazy-max commented 2 years ago

Isn't it better if the step will fail instead of the warning message?

Yes maybe we could add a strict mode to the action for semver and maybe also for invalid chars in image name and tags. Not sure if it should be global or per entries:

        tags: |
          type=edge,branch=main
          type=ref,event=branch
          type=ref,event=pr
          type=semver,pattern={{version}},strict=true
          type=semver,pattern={{major}}.{{minor}},strict=true
          type=semver,pattern={{major}},strict=true

Or through flavor?:

flavor: |
  strict=semver,image,tag

Need to think about it. Open to suggestions.

CAMOBAP commented 2 years ago

If you ask me (as a user) it will be nice to just extra input strict which handles all such situations (wrong/bad input). Some advance use cases like via flavor also can be useful, but for me strict: true will be enough