delete-package-versions
delete-package-versions copied to clipboard
Improve documentation/examples for dynamic version ids
Perhaps I'm too much of a n00b, but I'm finding it difficult to get this working with dynamic version ids.
My use case is that I build and push a docker container for every branch. The version (tag) on the container is the branch name. What I'd like to do is delete the versions which match the branch name when I delete the branch.
Here's what I've attempted
name: Delete branch tag
on:
delete:
branches: [ '**' ]
jobs:
cleanup:
runs-on: ubuntu-18.04
steps:
- uses: actions/delete-package-versions@v1
with:
package-version-ids: ${GITHUB_REF##*/}
But this results in an error:
Error: delete version mutation failed. Could not resolve to a node with the global id of '${GITHUB_REF##*/}'
The docs/examples don't give enough help/direction on how to get the version ids other than telling me to go look at the GH APIs. Is there a related action that I should use to get this, how have other people tackled deleting versions dynamically?
This action uses GraphQL which is not supported for containers:
GraphQL is not supported for containers or Docker images at ghcr.io.
Also, the Container Registry is still in beta.
I guess, the only solution for the moment is to manually delete our containers from the UI.
Otherwise, maybe try the following approach:
curl -s \
-X DELETE \
-H "Authorization: ${{ github.actor }} ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/orgs/{org}/packages/container/{name}/versions/{version}
Having the same issue using delete-package-versions@v2. See https://github.com/actions/delete-package-versions/issues/66#issuecomment-1055207022