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
| Input | Default | Description |
|---|---|---|
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 |
registry | ghcr.io | Registry host |
Outputs
| Output | Description |
|---|---|
image | Image reference without a tag, registry/owner/name, lowercase |
tags | The tags, space-separated |
names | image:tag for each tag, comma-separated |
raw-tags | One type=raw,value=<tag> line per tag, for docker/metadata-action |
cache | Registry layer-cache reference, <image>-cache:buildcache |
Tags
| Event | Tags |
|---|---|
| Any | sha-<7 characters> |
| Push to a branch | <branch> (/ and other characters → -) |
| Pull request | pr-<number> |
Push of a release tag vX.Y.Z | X.Y.Z, X.Y |
Push of a pre-release tag vX.Y.Z-pre | X.Y.Z-pre |
version set | the version as given, X.Y for a final release |
tag-latest on the default branch | latest |
Notes
X.Ybelongs to the final releases: a pre-release (v1.3.0-rc.2) keeps its own tag only. A release tag that is notvX.Y.Z[-pre]adds no version tag;tests/fixtures/release-tags.tsvholds 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-ghcrkeeps thebuildcachetag of the layer caches; a test fails when the two names differ.