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

Getting Error: Package not found. with GITHUB_TOKEN #105

Open
tzejohn opened this issue May 19, 2022 · 6 comments
Open

Getting Error: Package not found. with GITHUB_TOKEN #105

tzejohn opened this issue May 19, 2022 · 6 comments

Comments

@tzejohn
Copy link

tzejohn commented May 19, 2022

Here is the how the action is getting called:

Run bots-house/ghcr-delete-image-action@v1.0.0
  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.

@TaniyaVincent
Copy link

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

@mr-linch
Copy link
Member

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

@vlussenburg
Copy link
Collaborator

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

@mering
Copy link

mering commented Aug 21, 2023

Does it need permissions in addition to packages: write?

@gropaul
Copy link

gropaul commented Oct 20, 2023

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/ghcr-delete-image-action@v1.1.0
🔎 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

@williamdes
Copy link

${{ 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>

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

7 participants