Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
anchor

GitHub Action

Docker Image Update Checker

v1.2.0

Docker Image Update Checker

anchor

Docker Image Update Checker

GitHub Action to check if the base Docker image that your image is based on was updated and your image needs to be updated

Installation

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

              

- name: Docker Image Update Checker

uses: lucacome/docker-image-update-checker@v1.2.0

Learn more about this action in lucacome/docker-image-update-checker

Choose a version

Docker Image Update Checker Action

Test GitHub release badge GitHub license badge GitHub Workflows badge

Action to check if the base image was updated and your image (published on DockerHub) needs to be rebuilt. This action will use Docker's API to compare the base layers of your image with the base-image, without the need to pull the images.

Inputs

Name Type Description
base-image String Base Docker Image
image String Your image based on base-image
platforms String Platforms to check

Output

Name Type Description
needs-updating String 'true' or 'false' if the image needs to be updated or not

Examples

Minimal

Check if the image user/app:latest, that has nginx has a base image, needs to be updated:

name: Check docker image

on:
  schedule:
    - cron:  '0 4 * * *'

jobs:
  docker:
    runs-on: ubuntu-latest
    steps:
      - name: Check if update available
        id: check
        uses: lucacome/docker-image-update-checker@v1
        with:
          base-image: nginx:1.21.0
          image: user/app:latest

      - name: Check result
        run: echo "Needs updating: ${{ steps.check.outputs.needs-updating }}"

Single platform

Check if the image user/app:latest, that has nginx has a base image, needs to be updated:

name: Check docker image

on:
  schedule:
    - cron:  '0 4 * * *'

jobs:
  docker:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Check if update available
        id: check
        uses: lucacome/docker-image-update-checker@v1
        with:
          base-image: nginx:1.21.0
          image: user/app:latest

      - name: Build and push
        uses: docker/build-push-action@v3
        with:
          context: .
          push: true
          tags: user/app:latest
        if: steps.check.outputs.needs-updating == 'true'

Note

The platforms input is optional and defaults to linux/amd64.

Multiple platforms

Check if the image user/app:latest, that has nginx has a base image, needs to be updated for linux/amd64 and linux/arm64:

name: Check docker image for multiple platforms

on:
  schedule:
    - cron:  '0 4 * * *'

jobs:
  check:
    runs-on: ubuntu-latest
    outputs:
      needs-updating: ${{ steps.check.outputs.needs-updating }}
    steps:
      - name: Check if update available
        id: check
        uses: lucacome/docker-image-update-checker@v1
        with:
          base-image: nginx:1.21.0
          image: user/app:latest
          platforms: linux/amd64,linux/arm64

build:
    needs: check
    runs-on: ubuntu-latest
    if: needs.check.outputs.needs-updating == 'true'
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup QEMU
        uses: docker/setup-qemu-action@v2
        with:
          platforms: arm64

      - name: Docker Buildx
        uses: docker/setup-buildx-action@v2

      - name: Build and push
        uses: docker/build-push-action@v3
        with:
          context: .
          push: true
          tags: user/app:latest
          platforms: linux/amd64,linux/arm64

Note

If any of the platforms is not present in either the base-image or the image, the action will exit with an error.