I was successful in authenticating to the github container registry.
However I can't get it to pull or push any container images.
Looking at the REST API documentation:
https://docs.github.com/en/rest/packages/packages?apiVersion=2022-11-28#get-a-package-for-an-organization
It doesn't say that it works with github apps, like it does for this endpoint for instance:
https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#list-organization-repositories
From my experience some of the things in github isn't well documented so I did try, but in the end I couldn't get it to work.
I managed to successfully login using docker login
with a github app token, but still getting blocked by packages permissions when trying to push an image.
This is what I did to be able to login at least:
- Generate JWT for github app: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app
- Create access token: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-an-installation-access-token-for-a-github-app
- Login via docker:
docker login ghcr.io -u <YOUR_GITHUB_APP_ID>
and when prompted for password enter the token from the response in step 2.
My problem might be that the app is installed on the organization and I don't have enough permissions. When you generate your access token in the response you will see what kind of permissions it has. For it to work I guess it should have "packages" in the "permissions"
This is what I got in my response:
{
"token": "<redacted>",
"expires_at": "2023-08-11T08:44:17Z",
"permissions": {
"contents": "read",
"metadata": "read",
"packages": "write"
},
"repository_selection": "all"
}
But still failed with this when trying to push an image:
denied: permission_denied: installation not allowed to Create organization package