Skip to content
play

GitHub Action

docker-image-tag-exists

v2.1.0 Latest version

docker-image-tag-exists

play

docker-image-tag-exists

Check if a given container image tag exists in a registry

Installation

Copy and paste the following snippet into your .yml file.

              

- name: docker-image-tag-exists

uses: tyriis/[email protected]

Learn more about this action in tyriis/docker-image-tag-exists

Choose a version

taskfile pre-commit

Docker Image Tag Exists

This action query a docker container registry to check if a given tag exists.

Table of Contents

User Story

As a user I want to know if a docker image tag already exists in a registry, this is required to prevent same commit to be build more then once (f.e. re-tagging an existing image after a release workflow).

The Idea

In order to be able to determine if the container image already exists we can try to get the manifest data from the registry. If the manifest exists the image + tag exists otherwise the request will fail and the image tag is not found.

What's new

First implementation is currently tested, use at own risk

  • tested docker.io Registry

  • tested ghcr.io Registry

  • tested Google Artifact Registry

  • tested Amazon Elastic Container Registry

  • tested Harbor Registry

  • Issues with hosted arc runners in Google Cloud, implemented a http request as fallback, only tested with google cloud so far

  • replaced zx library with vanilla js and axios

Limitations

The return message of the registry is not standarized, please open a PR or create an issue if you encounter trouble with your registry.

Usage

- uses: tyriis/[email protected]
  with:
    # The container image registry
    registry: docker.io

    # The container image name
    repository: nginx

    # The container image tag
    tag: "1"

Outputs

name type description
tag string found or not found

License

The scripts and documentation in this project are released under the MIT License