ghcr-delete-image-action icon indicating copy to clipboard operation
ghcr-delete-image-action copied to clipboard

Getting Error: Package not found. with GITHUB_TOKEN

Open tzejohn opened this issue 2 years ago • 6 comments

Here is the how the action is getting called:

Run bots-house/[email protected]
  with:
    owner: abbvie-internal
    name: arch-ui-service
    token: ***
    tag: arch-ui-pr-2426

And I am seeing the error: Error: Package not found.

For the token, I am passing the secrets.GITHUB_TOKEN.

If I test this with octokit, making the same calls from my test node script.

import { Octokit, App } from "octokit";

const owner = "abbvie-internal";
const name = "arch-ui-service";

const octokit = new Octokit({ auth: `XXXXXXXXXXXXXXXXXXXXX` });

  for await (const response of octokit.paginate.iterator(
    octokit.rest.packages.getAllPackageVersionsForPackageOwnedByOrg,
    {
      package_type: "container",
      package_name: name,
      org: owner,
      state: "active",
      per_page: 100,
    }
  )) {
    for (let packageVersion of response.data) {
      console.log(packageVersion.metadata.container.tags);
    }
  }

This does find the package and returns metadata. The only difference is using a PAT as opposed to the GITHUB_TOKEN. I have not yet tried switching the github action to use the PAT to see if that makes a difference.

tzejohn avatar May 19 '22 15:05 tzejohn

Hello,

Can you mention the return code you are getting? I was getting a 204, which is genuine as the package got deleted and it couldn't return anything. However, I am using the PAT token added as Github secrets.

Regards, Taniya

TaniyaVincent avatar May 24 '22 18:05 TaniyaVincent

Using GITHUB_TOKEN would be more convenient. A little research on GitHub API is needed.

mr-linch avatar Feb 23 '23 19:02 mr-linch

@tzejohn I am using the plain vanilla GITHUB_TOKEN successfully. I would recommend you review what permissions you've given your workflow action :)

vlussenburg avatar Feb 23 '23 20:02 vlussenburg

Does it need permissions in addition to packages: write?

mering avatar Aug 21 '23 13:08 mering

I am getting a similar error, it says that it finds the image ID and the ID is also correct, but then it can't delete it.

Run bots-house/[email protected]
🔎 search package version with tag 0.0.1-alpha.[13]
🆔 package id is #139386911, delete it...
Error: Package not found.

My token has the following privileges image

I am not entirely sure whether this has the same context as the parent issue :) Thank you in advance! 🫶

[UPDATE] I managed the find my error: For packages where the privileges of the users are inherited from the repository they are linked to, only users with role admin are allowed to delete packages, for more information see here

gropaul avatar Oct 20 '23 09:10 gropaul

${{ secrets.GITHUB_TOKEN }} works fine.

permissions:
  contents: read # Checkout code
  packages: write # Push containers and manage tags

I got also the error Error: Package not found. and got it fixed because the name is not the repo name but the package name. This is unclear on the README

For me : https://github.com/wdes/mail-autodiscover-autoconfig/pkgs/container/mail-autodiscover-autoconfig%2Fmail-autodiscover-autoconfig

Gives: name: mail-autodiscover-autoconfig/mail-autodiscover-autoconfig Gives: name: <repo-name>/<container-name>

williamdes avatar Feb 14 '24 12:02 williamdes