This action check if an docker image already exist.
This action uses the experimental feature of Docker CLI docker manifest inspect
. This feature doesn't work with docker.pkg.github.com registry at the moment.
Required Regisry where the image is stored. Default "docker.io"
.
Required Regisry username.
Required Regisry password.
Required Image name with tag. Example: docker_account/my_image:tag
.
The value 1
if image exist, 0
if the image doesn't exist.
jobs:
job1:
name: My Job
runs-on: ubuntu-latest
steps:
- name: Check if image exist
id: is_image_exist
uses: KerberosMorphy/[email protected]
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
image: ${{ secrets.DOCKER_USERNAME }}/my_image:tag
- name: Publish Image if not exist
if: ((!steps.is_image_exist.outputs.image_exist))
# I recommend https://github.com/trilom/file-changes-action
# if you also want to check if Dockerfile
# have change since last push.
uses: docker/[email protected]
with:
name: ${{ secrets.DOCKER_USERNAME }}/my_image
username: ${{env.DOCKER_USERNAME}}
password: ${{env.DOCKER_PASSWORD}}
registry: docker.io