Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version_id parameter must be an integer #101

Open
lloeki opened this issue Apr 5, 2023 · 8 comments
Open

version_id parameter must be an integer #101

lloeki opened this issue Apr 5, 2023 · 8 comments

Comments

@lloeki
Copy link

lloeki commented Apr 5, 2023

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
@iampeters
Copy link

iampeters commented May 12, 2023

i am having the same issue @lloeki did you find a way around this?

@pbaroni-mdlz
Copy link

same issue here, version is 1.1.17

@rlaiola
Copy link

rlaiola commented May 17, 2023

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/versions

Example (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/versions

A JSON will be returned. You need an id like the one in the image below.

Screen Shot 2023-05-16 at 20 51 24

Hope it helps!

Cheers.

@pbaroni-mdlz
Copy link

same issue here, version is 1.1.17

Using "Version ID" instead of "Version", it worked:

image

@iampeters
Copy link

@pbaroni-mdlz how did you use it? Please share

@pbaroni-mdlz
Copy link

pbaroni-mdlz commented May 18, 2023

@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'

@derpda
Copy link

derpda commented Jun 16, 2023

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 :)

@abannachGrafana
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants