Skip to content

Action — image-tags ​

Computes the image name, tags and layer-cache reference of a container build from the event that triggered it. cd-buildkit (both build paths) and cd-docker use it, so every image of these workflows is tagged alike. It needs bash and no checkout.

Usage ​

yaml
steps:
  - id: image
    uses: KevinDeBenedetti/github-workflows/.github/actions/image-tags@main
    with:
      version: v1.2.3

  - uses: docker/build-push-action@v7
    with:
      tags: ${{ steps.image.outputs.names }}
      cache-from: type=registry,ref=${{ steps.image.outputs.cache }}

Inputs ​

InputDefaultDescription
image-name''Image name; empty uses the repository name
version''Explicit version tag (v1.2.3 also tags 1.2)
tag-latest'false''true' also tags latest on the default branch
registryghcr.ioRegistry host

Outputs ​

OutputDescription
imageImage reference without a tag, registry/owner/name, lowercase
tagsThe tags, space-separated
namesimage:tag for each tag, comma-separated
raw-tagsOne type=raw,value=<tag> line per tag, for docker/metadata-action
cacheRegistry layer-cache reference, <image>-cache:buildcache

Tags ​

EventTags
Anysha-<7 characters>
Push to a branch<branch> (/ and other characters → -)
Pull requestpr-<number>
Push of a release tag vX.Y.ZX.Y.Z, X.Y
Push of a pre-release tag vX.Y.Z-preX.Y.Z-pre
version setthe version as given, X.Y for a final release
tag-latest on the default branchlatest

Notes ​

  • X.Y belongs to the final releases: a pre-release (v1.3.0-rc.2) keeps its own tag only. A release tag that is not vX.Y.Z[-pre] adds no version tag; tests/fixtures/release-tags.tsv holds the tags this rule shares with the other release-tag rules of the repository.
  • A tag applied twice (a release tag pushed with the same version) appears once.
  • cleanup-ghcr keeps the buildcache tag of the layer caches; a test fails when the two names differ.