This action uses doctl to find and remove old images from Digital Ocean's Container Registry.
- Gets the repository manifests using
doctl registry repository lm
and orders them by theUpdatedAt
attribute. By default it will ignore the 10 most recent images - Then deletes the older images using
doctl registry repository delete-manifest
- Lastly triggers garbage collection to reclaim space in the registry
PRs are welcome.
Add this step to a job to automatically delete older images as part of a job:
steps:
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_API_KEY }}
- name: Remove old images from Container Registry
uses: henrik242/docr-image-remove@v1
with:
image_repository: image-repository # required
buffer_size: 10
exclude: ^(latest|tag1|tag2)$
image_repository
- (Required) Image repository name in the Container Registrybuffer_size
- (Optional) Number of recent images. Default is10
exclude
- (Optional) Regex expression to exclude in the tags to delete.
Based on these efforts:
- Initial work: https://github.com/ripplr-io/docr-image-remove
- Digests instead of tags: https://github.com/martintomas/docr-image-remove
- Exclude filter: https://github.com/NearSeaTechnologies/docr-image-remove
This GitHub Action and associated scripts and documentation in this project are released under the MIT License.