Skip to content

Document usage with the metadata-action #57

@oliv3r

Description

@oliv3r

It is not uncommon to use the metadata-action. E.g.

      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: |
            ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
          tags: |
            type=ref,event=branch
            type=ref,event=pr
            type=edge
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}
          flavor: |
            latest=auto

The idea of this is to generate the correct tag (if we are pushing a tag, otherwise a different tag gets created).

In such a case, how do we supply the image?

The build-and-push docker action uses the tag as

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

which in the end, is sensible if we where intended to run a pushed container

        uses: addnab/docker-run-action@v3
        with:
          image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags }}
        run: |

But this is obviously wrong, so then how can we use this action? Two scenario's are to be thought of. Upon pushing of a tag, where the container is also pushed into the ghcr, which is fine, and 'all other cases' e.g. pushes to master, pushes to a branch etc. How does this work, without pushing to ghcr and without using a fixed tag. (unless the answer is to always 'also' add a fixed tag, however that is done ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions