Documented API for reading the repository linked to a private GHCR package #214069
Replies: 3 comments
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
|
As far as I can find, there isn't a documented guarantee. In the REST API's schema, 1. Check the token's access to the repository. The field embeds a repository object, so it's worth checking whether your token can read the linked private repository at all. A classic PAT with only 2. Read the source label from the image itself. This is read-only and doesn't touch package settings. GitHub's Container registry docs define echo "$PAT" | crane auth login ghcr.io -u USERNAME --password-stdin
crane config ghcr.io/OWNER/IMAGE:TAG | jq -r '.config.Labels["org.opencontainers.image.source"]'
# or
skopeo inspect --creds USERNAME:$PAT docker://ghcr.io/OWNER/IMAGE:TAG | jq -r '.Labels["org.opencontainers.image.source"]'Limitation: the label is what the image was built with. If the repository was linked later in the package settings UI, the label won't reflect that link. The GraphQL Packages API isn't an option here. The docs say it can't be used with registries that support granular permissions, and the Container registry is one of them. |
|
The One thing worth testing first: use a token that can actually read the linked private repository. A classic PAT with only If you need this reliably for automation, I'd stop depending on the field. Add an OCI label at publish time — something like And yes, this is a reasonable docs/API request: either guarantee the field or document the conditions that populate it. |
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Bug
Body
A private GHCR package shows its linked repository in Package settings, but the documented REST API response omits the optional repository field.
Is there a supported read-only API or export that reliably returns the currently linked repository identity, without changing package permissions or visibility?
All reactions