anchore / grype-db

Apache License 2.0
34 stars 16 forks source link

Automation to delete OCI cache for provider #323

Open wagoodman opened 3 months ago

wagoodman commented 3 months ago

Today we have provider images that we create daily: https://github.com/orgs/anchore/packages?repo_name=grype-db

We always start with the latest cache on every data sync, however, there are instances where we want to delete todays cache for operational reasons. Ideally this should be done from a workflow that the @anchore/tools team can kick off. This is specifically important since image versions can only be deleted by admins, thus, only a small portion of the team can delete the latest image.

To list packages:

gh api \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  /orgs/anchore/packages/container/grype-db%2Fdata%2Fnvd/versions

List package versions: https://docs.github.com/en/rest/packages/packages?apiVersion=2022-11-28#list-package-versions-for-a-package-owned-by-an-organization

Ideally we should delete the package version: https://docs.github.com/en/rest/packages/packages?apiVersion=2022-11-28#delete-package-version-for-an-organization

Question: will this approach work for workflow_dispatch if the user kicking it off does not have admin rights?