Skip to content
Latchkey

docker/metadata-action: Generate Tags & Labels

metadata-action builds image tags and OCI labels from your Git context automatically.

Stop hand-writing tag logic. metadata-action turns branches, tags, SHAs, and semver into a tag set and labels, exposed as step outputs.

Key inputs (with:)

  • images: base image name(s) to tag.
  • tags: rules, e.g. type=semver,pattern={{version}}.
  • labels: extra OCI labels to add.
  • flavor: prefixes/suffixes and latest behavior.

Example workflow

.github/workflows/ci.yml
jobs:
  image:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - id: meta
        uses: docker/metadata-action@v5
        with:
          images: ghcr.io/${{ github.repository }}
          tags: |
            type=semver,pattern={{version}}
            type=sha
      - uses: docker/build-push-action@v6
        with:
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}

On any runner

metadata-action runs on any runner. Latchkey managed runners run it unchanged.

Key takeaways

  • Feed steps.meta.outputs.tags into build-push-action.
  • type=semver tags releases cleanly from Git tags.
  • It also emits standard OCI labels for free.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →