ghcr-delete-image-action
ghcr-delete-image-action copied to clipboard
Getting Error: Package not found. with GITHUB_TOKEN
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.
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
Using GITHUB_TOKEN
would be more convenient. A little research on GitHub API is needed.
@tzejohn I am using the plain vanilla GITHUB_TOKEN
successfully. I would recommend you review what permissions you've given your workflow action :)
Does it need permissions in addition to packages: write
?
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
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
${{ 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>