Skip to content
arrow-up-circle

GitHub Action

Update latest Docker tag

v0.1.0 Pre-release

Update latest Docker tag

arrow-up-circle

Update latest Docker tag

Update the latest tag of a Docker repo, but only if the new image is a (semver) newer version than what's there already.

Installation

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

              

- name: Update latest Docker tag

uses: silverlyra/latest-image-action@v0.1.0

Learn more about this action in silverlyra/latest-image-action

Choose a version

Latest image action

If you work on a project that publishes Docker images, you can add this action to your workflow to keep the Docker latest tag up to date.

Set either a label or ENV var containing your package’s version on your Docker images, and this action will update the latest tag only if the new version is actually newer (according to semver). This means that (e.g.) if you publish a patch release 1.2.4, but latest is 1.3.0, then latest won’t be “updated” to 1.2.4.

Note that the latest tag must already exist; this action will not create the tag initially.

Local Docker authentication is used; any existing Docker auth action that you’re already using like docker/login-action or AWS ECR login should work for this action, too.

- uses: silverlyra/latest-image-action
  with:
    repository: your/project
    candidate-tag: ${{ github.ref_name }}

Inputs

The following inputs are available on the action:

repository (required) 👈

The Docker image repository to update. If you image is published to multiple repositories, you can list each one on its own line:

- uses: silverlyra/latest-image-action
  with:
    repository: |
      some/project
      ghcr.io/some/project/project

candidate-tag (required) 👈

The Docker image tag that should (maybe) be promoted to latest.

This tag must be available in your workflow context, either as a Git tag name (${{ github.ref_name }}), or an output from a prior step.

with:
  candidate-tag: ${{ steps.current_version.outputs.version }}

latest-tag

default: latest

The Docker image tag to (conditionally) update.

version-source

default: label:org.opencontainers.image.version

Where the software version can be found in your Docker image metadata.

Use label:... to read an image label, or env:... to read a preset ENV var.

The default uses the version label from OpenContainers.

promote-prerelease

default: false

Allow a pre-release (e.g., alpha, beta, release-candidate) version to replace a non-pre-release latest.

coerce-semver

default: false

Use a coercing semver parser.

manifest-platform

default: linux/amd64

When updating a tag that points to a multi-arch manifest list (or OCI index), read the image configuration from the manifest for this platform.

Outputs

The action will set these outputs:

updated

Set to true if the latest tag was updated; false if not.

latest-version

Set to the version detected from the latest tag.

candidate-version

Set to the version detected from the candidate tag.