AI Hints
CI/CD with GitHub Actions · Lesson 81 of 138

Image Tags

Naming what you built.

⏱ 2 min read▶ Video at 1:33:52🎓 Free
Watch this lesson in the CI/CD with GitHub Actions courseWatch on YouTube ↗Full CI/CD with GitHub Actions course

A tag is the name after the colon in an image name. Shop colon latest, or shop colon one point two. Tags tell you which version is which. And picking good tags makes deployments and rollbacks much easier.

Image Tags
From the video: Image Tags
  • The part after the colon
  • Which version is which
  • Easier rollbacks

Tags from git

In a pipeline, tags usually come from git. Git rev parse gives the short commit SHA. We build a full image name from it, with the registry, the owner, and the name. That tag points to exactly one commit, forever.

Terminal
git rev-parse --short HEAD
7418016
echo "ghcr.io/sam/shop:sha-$(git rev-parse --short HEAD)"
ghcr.io/sam/shop:sha-7418016

Kinds of tags

Latest is convenient, but it moves, so you never know what it is. ASHA tag is exact, and perfect for deployments. A version tag, like one point two point zero, is for releases people can read. Many pipelines push all three, for the same image.

TagMoves?Use it for
latestyesquick local tries
sha-1a2b3c4neverdeployments
1.2.0neverreleases
1.2yesthe newest patch

Summary

Tag images with the commit SHA for deployments, and with a version for releases. Avoid deploying latest. Next, versions and git tags.

Key takeaways
  • sha- tags are exact
  • Versions for people
  • latest moves
Next up: Versions and Git Tags — naming releases