背景
为进一步闭环github
体系开发,镜像上传逐步向githubpackages
倾斜。
但是在向githubpackages
上传镜像时遇到一个较为糟糕的问题,就是按照目前现有教程是无法上传成功的。
报错
Using default tag: latest
The push refers to repository [ghcr.io/c-scale-community/hello-world]
e07ee1baac5f: Preparing
unauthorized: unauthenticated: User cannot be authenticated with the token provided.
修复
解决方案: 无法显式在每次推送镜像到githubPackages
时输入令牌,官方推荐将令牌暴露在某个局部变量中,在使用时引用即可。
export CR_PAT=YOUR_TOKEN
然后使用echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin
即可解决问题。