-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Badge Request: GitHub Container Registry #5594
Comments
Given this is essentially a feature related to the package registry, I suspect this one is probably going to end up blocked on #4169 (tldr: the github tokens we have don't have the necessary scope to read package metadata) once the API endpoints are available, but we'll see.. |
🙏 |
➕ |
To get the pull counter of the image published on ghcr, you can use PackageStatistics or PackageVersionStatistics in GraphQL API (needs auth). To get information of tags and sizes of public images on ghcr.io, you can use Here is my example with curl: # public image's {USER}/{IMAGE}
USER_IMAGE=eggplants/asciiquarium-docker
# get fake token ('{"token":"***"}' -> '***')
TOKEN="$(
curl "https://ghcr.io/token?scope=repository:${USER_IMAGE}:pull" |
awk -F'"' '$0=$4'
)"
_curl(){ curl -H "Authorization: Bearer ${TOKEN}" "$1" }
# get tags
_curl "https://ghcr.io/v2/${USER_IMAGE}/tags/list"
# >>> {"name":"eggplants/asciiquarium-docker","tags":["0.0.0","0.0","latest"]}
# get manifest of the latest image
_curl "https://ghcr.io/v2/${USER_IMAGE}/manifests/latest"
# >>>
# {
# "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
# "schemaVersion": 2,
# "config": {
# "mediaType": "application/vnd.docker.container.image.v1+json",
# "digest": "sha256:fb4552eacdc8e01082f87bae6a0fec6e1b61630f0a1e5a0e6a699d05ff0337fd",
# "size": 5551
# },
# "layers": [
# {
# "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
# "digest": "sha256:4be315f6562fccf08fd6c749557e31e45ab6d987370e20e2c4933ddb04ddd5ff",
# "size": 27140664
# }, ... |
Thank you for sharing @eggplants though to be clear, this is not blocked on the basics of the api request/response, but due to the associated scopes required by github, which our tokens do not have. This is blocked on that much bigger topic detailed in #4169 |
The number of pulls seems difficult to fetch, but it would be relatively easy to get just the tags and their image sizes, which do not require authentication. |
Gotcha, thanks for the clarification! In that case think it would probably make sense at this point to extract a separate issue for version and size badges to discuss the viability of the proposed approach, and we narrow the scope of this blocked one to pulls |
I have implemented eggplants/ghcr-badge on a trial basis: |
you can also hard code the token per image:
|
@asssaf Thanks! eggplants/ghcr-badge@f5504c4 |
…HTTP repos Note: did not yet differentiate the downloads badge between HTTP and OCI. A badge for GHCR package downloads is currently blocked. See: badges/shields#5594 Signed-off-by: Scott Rigby <[email protected]>
With the coming shutdown of free organizations on Docker Hub, we also plan to migrate to ghcr.io - what is the state of this implementation right now? I really do not want to stress this 😁 ! Take your time ❤️🔥 |
This comment was marked as off-topic.
This comment was marked as off-topic.
i'm trying with GraphQL api, and even with a Personal Access Token set in headers, I don't receive any package in the results
query {
organization(login: "oxsecurity") {
name
isVerified
packages(first: 100) {
nodes {
name
packageType
statistics {
downloadsTotalCount
}
}
}
}
}
{
"data": {
"organization": {
"name": "OX Security",
"isVerified": true,
"packages": {
"nodes": []
}
}
}
} |
@nvuillam It doesn't seem to work. |
That' really sad :( Thanks for the reply ! |
@nvuillam try a repository query (instead of an organization query) to get the packages for the megalinter repository. It looks like all of your public packages are associated with that repository, so that might work. I didn't try this so I don't know for sure if it will work, but I think it might. |
@cicirello You can try this query from https://docs.github.com/en/graphql/overview/explorer. And query {
repository(owner: "oxsecurity", name: "megalinter") {
name
packages(first: 1) {
nodes {
name
packageType
statistics {
downloadsTotalCount
}
}
}
}
} Note that |
I confirm, I still did not find any way to query stats for MegaLinter packages :/ |
It's sad that the GraphQL API from GitHub doesn't work. I ended up with a tool to parse the HTML page and list only named versions
|
I thought to build something similar, like github-dependent-infos scraps to get the number and list of dependent repos... But a working API would be the best, we're just looking for simple numbers :( |
I made a JSON endpoint for the downloads, size, and more (including for each version/tag!) that can be used to make a badge. Just star the repo to have your packages added! Example: |
This is fantastic! I would love support for tags, though. My main use case is here: https://github.com/linuxserver/docker-mods/pkgs/container/mods/ Trying to mess with it now... |
@TheCaptain989 I've got version support mostly implemented! I'm also expanding support to all package types on GitHub Packages and want to add sizes for each version to the json, but I haven't looked into whether it's possible to get the sizes via rest api/scraping/graphql. Does anyone know how/if I could get the sizes? ghcr-badge and, at the moment, my repo cheat for |
@ipitio I read your current approach and you are only scraping the page source of GitHub Package directly without using docker manifests. Is it used in commits that have not yet been pushed in version support? Anyway, this may be broken in the future due to modification of the page structure. The version and number of downloads can be obtained from the HTML source, but the size must be referenced in the docker manifest. Based on my research for now:
|
I've got size working using the manifest on the dev branch, where I've implemented version support too. Will merge the changes to master soon! https://github.com/ipitio/ghcr-pulls/blob/dev/update.sh |
Awesome. |
I guess I’m a little confused why I am getting emails about another project within this issue. Wouldn’t it be better that you open a discussion on your own repo? |
Sorry! I've made a discussion here: ipitio/backage#9 |
📋 Description
GitHub recently introduced the GitHub Container Registry (see: https://github.blog/2020-09-01-introducing-github-container-registry/). It would be nice if there were badges available similar to those that shields has for Docker image version, image size, and pulls, but for the new GitHub Container Registry.
🔗 Data
I'm not sure if GitHub has an API for this yet.
🎤 Motivation
Motivation is the same as that of the equivalent badges that already exist for Docker Hub, but targeting the GitHub Container Registry instead. Providing a nice concise visual summary of some of the key statistics one might be interested in with a Docker image, but for images available in the GCR.
The text was updated successfully, but these errors were encountered: