I want to know what images are uploaded to a specific owner in GitHub Container Registry. Containers are referred like this: https://ghcr.io/OWNER/<imageName>:<imageTag>

- 75
- 1
- 5
3 Answers
You can use the GitHub Packages API.
The API requires authentication. You can use a personal token.
With Octokit:
import { Octokit } from "@octokit/rest";
const octokit = new Octokit({ auth: "<YOUR TOKEN> " });
const username = "django";
await octokit.rest.packages
.listPackagesForUser({ package_type: "container", username })
.then(
async ({ data }) =>
await Promise.all(
data.map(
async (container) =>
await octokit.rest.packages
.getAllPackageVersionsForPackageOwnedByUser({
package_type: container.package_type,
username,
package_name: container.name,
})
.then(({ data }) =>
data.map((image) => {
return {
container: container.name,
name: image.name,
tags: image?.metadata?.container?.tags ?? [],
};
})
)
)
)
)
.then((result) => console.log(result.flat()));
Output:
[
{
container: 'code.djangoproject.com',
name: 'sha256:eba6cf86886c5920dba74cbe579e9ab996851e6a9232d1095afa92e9d2901616',
tags: [ 'sha-d679c9a', 'latest', 'main' ]
},
{
container: 'code.djangoproject.com',
name: 'sha256:4b2472bfcc3218f5396830c865592628056864c5a65015e9d32d75234941b934',
tags: [ 'sha-019618e' ]
},
{
container: 'code.djangoproject.com',
name: 'sha256:f9fe5334a871286f0a75710d3c38b00e07aa8dd90cd206644155136ef835f278',
tags: [ 'sha-db2c406' ]
},
{
container: 'code.djangoproject.com',
name: 'sha256:99ad57b1bb7ca2d82f3e1abb61f496c9ae7dc7a0e4721c595b107afe85ab03ea',
tags: [ 'sha-19a7a14' ]
},
{
container: 'code.djangoproject.com',
name: 'sha256:1d284e53531f9a0e963ad843bce395453467bdd0ee0b89b9ab231a72cea6f10a',
tags: [ 'sha-0a02bc3', 'docker' ]
}
]

- 9,451
- 2
- 33
- 59
-
Thank you for sharing this. Really helped. Wish I could do this in Python though - not used to js at all. Still, you saved the day, @tugrul-ates – Saurabh Sawhney May 26 '23 at 03:56
If you published a package to GHCR and want to see it in the browser UI, go to this URL:
https://github.com/username?tab=packages
Just replace 'username' with your username.

- 41,291
- 27
- 223
- 311
You can list images (packages) also from within GitHub UI.
List of packages can be found when you simply navigate to a specific GitHub project such as https://github.com/fluxcd/flux2 and in the right panel you can see and click Packages
button.
The URL for container GitHub package window is in format https://github.com/<ORGANIZATION>/<PROJECT>/pkgs/container/<PACKAGE>
. Here is example URL for Flux2 CLI - https://github.com/fluxcd/flux2/pkgs/container/flux-cli.
From there it is also possible to list all pushed tags.

- 407
- 5
- 8