Skip to content

alesharik/delete-old-docker-tags

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

typescript-action status

Delete old github tags

GitHub action to delete old tags from docker registry.

It will:

  1. Fetch all tags for specified image
  2. Extract semver versions from them. If extraction fails, tag will be ignored (so latest and other tags like it will be safe)
  3. Sort extracted versions in descending order
  4. Deletes all tags below keep-last position in sorted list. This deletes manifests too, so if deleted tag points to latest manifest, these two tags will be deleted

Inputs

Name Description Required Default
registry Registry URL (with http/https) ✔️
username Username to login into registry ✔️
password Password to login into registry ✔️
repository Repository/image name to fetch tags from ✔️
keep-last How much versions to keep 10
version-extractor Regex to extract SemVer version from tag v?(\d+(.\d+)*)

Example usage

Keep 10 last versions of image

uses: alesharik/[email protected]
with:
  registry: https://registry.url
  username: ${{ secrets.DOCKER_USERNAME }}
  password: ${{ secrets.DOCKER_PASSWORD }}
  repository: test

Keep 5 last versions of image

uses: alesharik/[email protected]
with:
  registry: https://registry.url
  username: ${{ secrets.DOCKER_USERNAME }}
  password: ${{ secrets.DOCKER_PASSWORD }}
  repository: test
  keep-last: 5

Keep 5 last versions of dev images

uses: alesharik/[email protected]
with:
  registry: https://registry.url
  username: ${{ secrets.DOCKER_USERNAME }}
  password: ${{ secrets.DOCKER_PASSWORD }}
  repository: test
  keep-last: 5
  version-extractor: 'v?(\d+(.\d+)*)-dev'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published