https://github.com/doodlescheduling/gh-package-retention
Package rentention github action and cli extension for ghcr.io
https://github.com/doodlescheduling/gh-package-retention
cleanup ghcr github-action github-extension github-packages package-retention retention
Last synced: 6 months ago
JSON representation
Package rentention github action and cli extension for ghcr.io
- Host: GitHub
- URL: https://github.com/doodlescheduling/gh-package-retention
- Owner: DoodleScheduling
- License: apache-2.0
- Created: 2023-04-12T14:20:27.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-11T11:57:37.000Z (7 months ago)
- Last Synced: 2025-03-11T12:36:39.659Z (7 months ago)
- Topics: cleanup, ghcr, github-action, github-extension, github-packages, package-retention, retention
- Language: Go
- Homepage:
- Size: 130 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
## ghcr.io package retention
[](https://github.com/DoodleScheduling/gh-package-retention/releases)
[](https://github.com/doodlescheduling/package-retention/actions/workflows/release.yaml)
[](https://goreportcard.com/report/github.com/DoodleScheduling/gh-package-retention)
[](https://coveralls.io/github/DoodleScheduling/gh-package-retention?branch=master)
[](https://github.com/DoodleScheduling/gh-package-retention/blob/master/LICENSE)Package retention manager for ghcr.io.
Unlike other apps implementing a similar mechanism this one actually has support for docker manifests
and can do retentions for multi platform image tags.* Delete packages based on age (and optionally in combination with a regex filter)
* Supports rentention for multi platform container images (and all other package types)## Usage
This example will remove package versions older than 3000h from the maven repositories package and anotherpackage:
```
package-retention --org-name githuborgname --package-type maven --age 3000h package anotherpackage
```## Installation
### Brew
```
brew tap doodlescheduling/gh-package-retention
brew install gh-package-retention
```### Docker
```
docker pull ghcr.io/doodlescheduling/gh-package-retention:v2
```### Github cli extenion
```
gh extension install DoodleScheduling/gh-package-retention
```## Arguments
| Flag | Env | Default | Description |
| ------------- | ------------- | ------------- | ------------- |
| `` | `PACKAGES` | `` | **REQUIRED**: One or more paths comma separated to kustomize |
| `--package-type` | `PACKAGE_TYPE` | `` | **REQUIRED**: Type of package (container, maven, ...) |
| `--org-name` | `ORG_NAME` | `` | **REQUIRED**: Github organization name which is the package owner |
| `--age` | `AGE` | `` | Max age of a package version. Package versions older than the specified age will be removed (As long as version-match macthes the version). |
| `--yes` | `YES` | `false` | Delete packages. By default retention-package runs in a dry mode. |
| `--log-encoding` | `LOG_ENCODING` | `console` | Log encoding format. Can be 'json' or 'console'. (default "console") |
| `--log-level` | `LOG_LEVEL` | `info` | Log verbosity level. Can be one of 'trace', 'debug', 'info', 'error'. (default "info") |
| `--token` | `GITHUB_TOKEN` | `1.27.0` | Github token (By default GITHUB_TOKEN will be used) |
| `--version-match` | `VERSION_MATCH` | `` | Regex to match a version. Note for containers it will match container tags (If package-type is container)' |## Github Action
This app works also great on CI, in fact this was the original reason why it was created.
### Example usage
```yaml
name: package-retention
on:
schedule:
- cron: '0 0 * * *'
jobs:
package-retention:
permissions:
packages: write
runs-on: ubuntu-latest
steps:
- uses: docker://ghcr.io/doodlescheduling/gh-package-retention@sha256:bc6b277986d5a8d0a1c2f67f148cf66bfb40710d6f557b355bf02016bdfdb57c # v2.0.1
name: Delete oci helm charts older than 90 days
env:
PACKAGES: charts/${{ github.event.repository.name }}
PACKAGE_TYPE: container
AGE: 2160h
VERSION_MATCH: 0.0.0-.*
- uses: docker://ghcr.io/doodlescheduling/gh-package-retention@sha256:bc6b277986d5a8d0a1c2f67f148cf66bfb40710d6f557b355bf02016bdfdb57c # v2.0.1
name: Delete maven snapshot versions older than 90 days
with:
PACKAGES: org.example.mypackage
PACKAGE_TYPE: maven
AGE: 2160h
VERSION_MATCH: ".*-SNAPSHOT$"
```