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

Document usage with the metadata-action #57

Open
oliv3r opened this issue Aug 8, 2024 · 0 comments
Open

Document usage with the metadata-action #57

oliv3r opened this issue Aug 8, 2024 · 0 comments

Comments

@oliv3r
Copy link

oliv3r commented Aug 8, 2024

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

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

No branches or pull requests

1 participant