eggplants / ghcr-badge

Generate ghcr.io (GitHub Container Registory) container's status badge
https://ghcr-badge.egpl.dev
MIT License
38 stars 10 forks source link

Total pulls count #72

Closed kroese closed 4 months ago

kroese commented 1 year ago

It would be nice to have a badge that display the total pulls count, like is possible with Dockerhub badges. I dont know if GHCR provides this information, or that it is only available per image. In that case the badge would need to sum up all values, but that might be too resource-intensive.

eggplants commented 1 year ago

It can be fetched with not Docker Registry API but GitHub GraphQL API.

https://docs.github.com/en/graphql/reference/objects#packagestatistics

https://docs.github.com/en/graphql/reference/objects#packageversionstatistics

But I think it is out of scope this badge service for now. If you want to use this feature, please send your PR. I'll welcome.

zhilyaev commented 1 year ago

This will be awesome!

razonyang commented 1 year ago

+1 for this feature, most of the users of my images prefer to use GHCR than Docker Hub, the number of downloads is almost surpassing Docker Hub's.

eggplants commented 1 year ago

It can be fetched with not Docker Registry API but GitHub GraphQL API.

https://docs.github.com/en/graphql/reference/objects#packagestatistics

https://docs.github.com/en/graphql/reference/objects#packageversionstatistics

GraphQL Query for repo packages seems dead due to deprecation. https://github.blog/changelog/2022-08-18-deprecation-notice-graphql-for-packages/

And I confirmed these queries are currently not working.

image

Sadly, there does not seem to be a replacement for PackageVersionStatistics in the REST API. https://docs.github.com/en/free-pro-team@latest/rest/packages/packages?apiVersion=2022-11-28

razonyang commented 11 months ago

What about parsing HTML other than using API as a provisional solution?

kroese commented 4 months ago

This now implemented in: https://github.com/ipitio/badpack