Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Flag in Raw Tag does not work as expected #461

Open
3 tasks done
baxterjo opened this issue Oct 7, 2024 · 2 comments
Open
3 tasks done

Enable Flag in Raw Tag does not work as expected #461

baxterjo opened this issue Oct 7, 2024 · 2 comments

Comments

@baxterjo
Copy link

baxterjo commented Oct 7, 2024

Contributing guidelines

I've found a bug, and:

  • The documentation does not mention anything about my problem
  • There are no open or closed issues that are related to my problem

Description

When using a raw tag with the enable flag, the tag is still in the metadata output when enable is set to false.

Expected behaviour

Run docker/metadata-action@v5
Context info
Processing images input
Processing tags input
  type=semver,pattern={{raw}},value=v0.0.1+test,enable=true,priority=900
  type=raw,value=latest,enable=false,priority=200
Processing flavor input
Docker image version
Docker tags
  ghcr.io/{org}/{image}:v0.0.1-test
Docker labels
Annotations
JSON output
Bake file definition (tags)
Bake file definition (labels)
Bake file definition (annotations)

Actual behaviour

Run docker/metadata-action@v5
Context info
Processing images input
Processing tags input
  type=semver,pattern={{raw}},value=v0.0.1+test,enable=true,priority=900
  type=raw,value=latest,enable=false,priority=200
Processing flavor input
Docker image version
Docker tags
  ghcr.io/{org}/{image}:v0.0.1-test
  ghcr.io/{org}/{image}:latest
Docker labels
Annotations
JSON output
Bake file definition (tags)
Bake file definition (labels)
Bake file definition (annotations)

Repository URL

No response

Workflow run URL

No response

YAML workflow

- name: Docker Meta
  id: meta
  uses: docker/metadata-action@v5
  with:
    images: ${{ needs.set-workflow-vars.outputs.image-name }}
    tags: |
      type=semver,pattern={{raw}},value=${{ needs.set-workflow-vars.outputs.version }}
      type=raw,value=latest,enable=${{ inputs.is-latest }} # This input is typed as a boolean in the callable workflow, maybe that's it?

Workflow logs

Run docker/metadata-action@v5
Context info
Processing images input
Processing tags input
  type=semver,pattern={{raw}},value=v0.0.1+test,enable=true,priority=900
  type=raw,value=latest,enable=false,priority=200
Processing flavor input
Docker image version
Docker tags
  ghcr.io/{org}/{image}:v0.0.1-test
  ghcr.io/{org}/{image}:latest
Docker labels
Annotations
JSON output
Bake file definition (tags)
Bake file definition (labels)
Bake file definition (annotations)

BuildKit logs

No response

Additional info

No response

@crazy-max
Copy link
Member

type=raw,value=latest,enable=${{ inputs.is-latest }}

Do you repro as well with type=raw,value=latest,enable=false? If not then that might be related to how GitHub handles boolean inputs.

@baxterjo
Copy link
Author

baxterjo commented Dec 9, 2024

type=raw,value=latest,enable=${{ inputs.is-latest }}

Do you repro as well with type=raw,value=latest,enable=false? If not then that might be related to how GitHub handles boolean inputs.

Yea that question is in the comment of the line where the bug originates from. It is a GHA typed boolean for sure. The peculiar thing is the fix I ended up going with.

Intsead of

- name: Docker Meta
  id: meta
  uses: docker/metadata-action@v5
  with:
    images: ${{ needs.set-workflow-vars.outputs.image-name }}
    tags: |
      type=semver,pattern={{raw}},value=${{ needs.set-workflow-vars.outputs.version }}
      type=raw,value=latest,enable=${{ inputs.is-latest }} # This input is typed as a boolean in the callable workflow, maybe that's it?

I ended up using the flavor input. Which is documented the same as tags as far as booleans go:

- name: Docker Meta
   id: meta
   uses: docker/metadata-action@v5
   with:
     images: ${{ steps.set-vars.outputs.image-name }}
     flavor: |
       latest=${{ inputs.is-latest }}
     tags: |
       type=semver,pattern={{raw}},value=${{ inputs.version }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants