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.
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.
kedai-kancil:1.2.0You 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
git tag v0.1.0git push origin v0.1.0
0 of 4 steps done · Your ticks are saved.
Bahasa Melayu
Peti sejuk kedai ada 40 pek, semuanya berlabel latest. Satu pek buat pelanggan sakit. Pek yang mana satu?
Tag (label) ialah label pada pek. docker/metadata-action tulis untuk anda. Setiap peraturan tambah satu label bila ia sesuai dengan event.
Pilih satu event dan tekan Run. Kemudian ketik stesen untuk baca log. Log itu senaraikan tag. Cuba ketiga-tiga event.
Event mana buat tag mana?
Anda push tag v1.3.0-rc.1, satu release ujian. Tag apa yang keluar?
Leret ke kanan kalau tag itu bagus untuk production. Leret ke kiri kalau perlu dibaiki.
Kini anda boleh beri setiap image tag yang jelas dan boleh dijejak.
You finished this before. Practice is always welcome!
Official docs: docker/metadata-action · Docker docs: tags and labels with GitHub Actions
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?