docker/metadata-action@v6
GitHub Action to extract metadata (tags, labels) for Docker
At a glance
- Latest major
v6- Repository
- docker/metadata-action
- Inputs
- 11 (2 required)
- Outputs
- 10
- Runs using
node24- License
- Apache-2.0
- Last checked
Inputs and outputs come straight from the action's official action.yml. See our editorial standards.
Usage
- uses: docker/metadata-action@v6Inputs
| Name | Required | Default | Description |
|---|---|---|---|
context | Yes | workflow | Where to get context data. Allowed options are "workflow" (default), "git". |
images | No | none | List of Docker images to use as base name for tags |
tags | No | none | List of tags as key-value pair attributes |
flavor | No | none | Flavors to apply |
labels | No | none | List of custom labels |
annotations | No | none | List of custom annotations |
sep-tags | No | none | Separator to use for tags output (default \n) |
sep-labels | No | none | Separator to use for labels output (default \n) |
sep-annotations | No | none | Separator to use for annotations output (default \n) |
bake-target | No | none | Bake target name (default docker-metadata-action) |
github-token | Yes | ${{ github.token }} | GitHub Token as provided by secrets |
Outputs
| Name | Description |
|---|---|
version | Generated Docker image version |
tags | Generated Docker tags |
tag-names | Generated Docker tag names without image base name |
labels | Generated Docker labels |
annotations | Generated annotations |
json | JSON output of tags and labels |
bake-file-tags | Bake definition file with tags |
bake-file-labels | Bake definition file with labels |
bake-file-annotations | Bake definition file with annotations |
bake-file | Bake definition file with tags and labels |
Read an output with ${{ steps.<step-id>.outputs.<name> }}; the step needs an id.
Examples
Generate tags and labels
Derive image tags from branches, tags and the commit SHA instead of hand-writing them.
name: Example
on:
push:
branches: [main]
permissions:
contents: read
jobs:
example:
runs-on: ubuntu-latest
steps:
- name: Docker Metadata action
id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=sha
- name: Use the output
run: echo "tags = ${{ steps.meta.outputs.tags }}"Each example passed actionlint (syntax, expressions and the inputs it knows for this action). They were not run in a live repository, so replace placeholder values such as names, ARNs and paths with your own.
Something out of date or wrong? Report it on our Contact page. This page is rebuilt from the action's repository roughly once a week.