Skip to content

GitHub Action to check if a docker container image exists in a registry.

License

Notifications You must be signed in to change notification settings

tyriis/docker-image-tag-exists

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

pre-commit taskfile

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 curl request as fallback, only tested with google cloud so far

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