World map

 

BM: Baca dalam Bahasa Melayu

World C2: Container Pipelines

Smart tags with metadata-action

You will learn: to label every image with its branch, version and commit.

Checked with GitHub Actions 2026-10 on 31 Oct 2026

The problem

The shop freezer holds 40 packs, all labelled latest. One pack made a customer sick. Which pack was it?

Pick one answer.

Watch

Tap the rule that writes the batch code: the commit.

0 of 1 found

image tag: A label on the pack, like 1.2.0, main or sha-3f9c2a7. One image can carry many. are labels on the pack. docker/metadata-action writes them for you. Each rule adds a label when it fits the event.

Watch

Pick an event. Press Run and watch the line.

The metadata step prints the tags for the event you pick: push to main, a pull request, or a version tag.

What happened on GitHub

Workflow file .github/workflows/tags.yml

name: Tags
on:
push:
branches: [main]
tags: ['v*']
pull_request:
permissions:
contents: read
jobs:
tags:
runs-on: ubuntu-latest
steps:
- id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/you/kedai-kancil
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha

The line

Push to main · main

Pick an event and press Run. Then tap the station to read its log. The log lists the tags. Try all three events.

Try it

Which event makes which tag?

Drag a card into a box. Or tap the card, then tap the box.

        Predict

        You push the tag v1.3.0-rc.1, a test release. Which tags appear?

        Pick one answer.

        Check

        Swipe right if the tag is good for production. Swipe left if it needs work.

        Swipe right for good, left for needs work. Or use the buttons.

        1 / 4kedai-kancil:1.2.0
        kedai-kancil:1.2.0

        You did it!

        You can now give every image clear, traceable tags.

        Go deeper (optional)

        Add type=semver,pattern={{major}}.{{minor}} to also get 1.2. Set flavor: latest=false to stop latest. metadata-action also writes labels: pass labels: ${{ steps.meta.outputs.labels }} to the build.

        Real rep (optional), in a public practice repo:

        Real mission

        1. git tag v0.1.0
        2. git push origin v0.1.0

        0 of 4 steps done · Your ticks are saved.