跳到主要内容

githubPackages上传踩坑

· 阅读需 1 分钟

背景

为进一步闭环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即可解决问题。