Compute Image Tags in CI
CI pushes the label-printer image with every tag printed by /home/student/projects/label-printer/ci/image-tags.sh. Pushes fail on branches like feature/Login-Page (invalid reference format), and latest points at whatever branch was built last.
Fix ci/image-tags.sh. It reads IMAGE (like registry.example.com/shop/api), GIT_REF, GIT_SHA (40 hex characters) and DEFAULT_BRANCH (default main), and prints one full image reference per line (IMAGE:tag), each once:
| GIT_REF | Tags |
|---|---|
| any | sha-<first 7 characters of GIT_SHA> |
refs/heads/<branch> | the branch slug, plus edge if it's the default branch |
refs/tags/vX.Y.Z (numbers) | X.Y.Z, X.Y, X and latest |
refs/tags/vX.Y.Z-<pre> | only X.Y.Z-<pre> (a pre-release never moves latest) |
refs/pull/<n>/merge | pr-<n> |
The slug of a branch: lowercase; every character other than a-z 0-9 . _ - becomes -; leading . and - removed; at most 128 characters.
When IMAGE, GIT_REF or GIT_SHA is missing, print an error to stderr and exit non-zero.
About this machine
Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.
Part of Docker Fundamentals. Next step: Start Debug Tools Only When Asked
Teaching or writing about this? Embed this lab on your page
Your machine is ready to start
A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.
No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.