Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bots-house/ghcr-delete-image-action

♻️ Delete GitHub Container Registry image by tag
https://github.com/bots-house/ghcr-delete-image-action

github-actions github-container-registry

Last synced: 4 months ago
JSON representation

♻️ Delete GitHub Container Registry image by tag

Awesome Lists containing this project

README

        

# ghcr-delete-image

[![CI](https://github.com/bots-house/ghcr-delete-image-action/actions/workflows/ci.yml/badge.svg)](https://github.com/bots-house/ghcr-delete-image-action/actions/workflows/ci.yml)
[![wakatime](https://wakatime.com/badge/github/bots-house/ghcr-delete-image-action.svg)](https://wakatime.com/badge/github/bots-house/ghcr-delete-image-action)

Delete image from [Github Container Registry](https://github.com/features/packages) by tag.
Useful for cleanup of pull request scoped images.

## Usage

## Delete image when PR was closed.

```yaml
name: Cleanup PR Images

on:
pull_request:
types: [closed]

jobs:
purge-image:
name: Delete image from ghcr.io
runs-on: ubuntu-latest
steps:
- name: Delete image
uses: bots-house/[email protected]
with:
# NOTE: at now only orgs is supported
owner: bots-house
name: some-web-service
# NOTE: using Personal Access Token
token: ${{ secrets.PAT }}
tag: pr-${{github.event.pull_request.number}}
```

## Keep latest N untagged images

```yaml
name: Cleanup Untagged Images

on:
# every sunday at 00:00
schedule:
- cron: "0 0 * * SUN"
# or manually
workflow_dispatch:

jobs:
delete-untagged-images:
name: Delete Untagged Images
runs-on: ubuntu-latest
steps:
- uses: bots-house/[email protected]
with:
# NOTE: at now only orgs is supported
owner: bots-house
name: some-web-service
# NOTE: using Personal Access Token
token: ${{ secrets.PAT }}
# Keep latest N untagged images
untagged-keep-latest: 3
```