version_id parameter must be an integer
lloeki opened this issue ยท 8 comments
So I'm hitting this strange issue I can't quite explain when deleting a package version on ghcr.io:
Error: delete version API failed. The version_id parameter must be an integer.
Full output:
Run actions/delete-package-versions@v4
with:
package-version-ids: gha4622410040-g3d94762cffc166ff549a28c3710ca44cdddc4f2a
package-name: system-tests/runner
package-type: container
num-old-versions-to-delete: 1
min-versions-to-keep: -1
ignore-versions: ^$
delete-only-pre-release-versions: false
delete-only-untagged-versions: false
token: ***
env:
REGISTRY: ghcr.io
Total versions deleted till now: 1
Error: delete version API failed. The version_id parameter must be an integer.
0 versions deleted till now.
Usage in workflow:
steps:
...
- uses: actions/delete-package-versions@v4
with:
package-version-ids: gha${{ github.run_id }}-g${{ github.sha }}
package-name: system-tests/${{ matrix.image }}
package-type: 'container'
continue-on-error: true
same issue here, version is 1.1.17
I managed to get actions/delete-package-versions@v4 working using the actual version id on ghcr.io (not the digest). In order to obtain that for a package owned by a user, see the documentation here.
Listing package versions for a package owned by a user (cURL):
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/users/USERNAME/packages/PACKAGE_TYPE/PACKAGE_NAME/versionsExample (replace <YOUR-TOKEN> accordingly):
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/users/rlaiola/packages/container/relax-docker/versionsA JSON will be returned. You need an id like the one in the image below.
Hope it helps!
Cheers.
@pbaroni-mdlz how did you use it? Please share
@pbaroni-mdlz how did you use it? Please share
- name: Get Version ID from the Versions List
id: version-id
run: |
curl -X GET -H "Authorization: Bearer ${{env.GITHUB_TOKEN}}" https://api.github.com/orgs/YOUR_ORG/packages/YOUR_PACKAGE_TYPE/YOUR_PACKAGE_NAME/versions >> $HOME/versionIds.json
echo "VERSION_ID=$(jq -r '.[] | select(.name == "1.1.7").id' $HOME/versionIds.json)" >> $GITHUB_OUTPUT
- name: Print Version ID
run: echo "The selected Version ID is ${{ steps.version-id.outputs.VERSION_ID }}"
- uses: actions/delete-package-versions@v4
with:
package-version-ids: '${{ steps.version-id.outputs.VERSION_ID }}'
package-name: 'YOUR_PACKAGE_NAME'
package-type: 'maven'
The documentation specifically lists below example
- uses: actions/delete-package-versions@v4
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
package-name: 'test-package'
package-type: 'npm'
As in, a string should be accepted, so this seems to be a bug.
As suggested in the same Readme, I get that string from the GitHub GraphQL API, not sure that an int version is even available there.
If there is an int verison, could someone let me know how to acquire it?
EDIT: Went back and checked on version 3.0.1, and it works fine there with a string. Something happened in between :)
I agree with this being a bug. I'm using this action with a workflow where I create a temporary container image to use as a service in other jobs and want to delete afterwards. I see my version as the tag on the container e.g. ghcr.io/foo/bar:my-version-1 would be version my-version-1. At the time of pushing my package via docker I would not know what the internal package id is, but I do know what the version tag is.
If there was an action that could build and publish my image and the output of that step was the package id i could use later that'd save having to do an API call and parsing the response.
