从 github 操作服务登录私人存储库中的 github 包注册表
Login github package registry in private repository from github action service
我们正在尝试使用托管在我们组织的 Github 包中的私有 docker 图像。像这样:
on: push
jobs:
runner-job:
runs-on: ubuntu-latest
services:
postgres:
# Github Registry image here
image: ghcr.io/orgname/reponame:tag
但是我们遇到了未经授权的错误,这是正常的,因为注册表是私有的。有什么方法可以登录吗?我还没有找到任何方法或文档。
您必须将 credentials 添加到每个使用私有存储库中的图像的服务。来自文档:
If the image's container registry requires authentication to pull the image, you can use credentials
to set a map
of the username
and password
. The credentials are the same values that you would provide to the docker login command.
这是一个例子:
on: push
jobs:
runner-job:
runs-on: ubuntu-latest
services:
postgres:
image: ghcr.io/orgname/reponame:tag
# add this to each service with an image from a private repo
credentials:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
此示例意味着您有两个 secrets:DOCKER_USER
和 DOCKER_PASSWORD
。
我们正在尝试使用托管在我们组织的 Github 包中的私有 docker 图像。像这样:
on: push
jobs:
runner-job:
runs-on: ubuntu-latest
services:
postgres:
# Github Registry image here
image: ghcr.io/orgname/reponame:tag
但是我们遇到了未经授权的错误,这是正常的,因为注册表是私有的。有什么方法可以登录吗?我还没有找到任何方法或文档。
您必须将 credentials 添加到每个使用私有存储库中的图像的服务。来自文档:
If the image's container registry requires authentication to pull the image, you can use
credentials
to set amap
of theusername
andpassword
. The credentials are the same values that you would provide to the docker login command.
这是一个例子:
on: push
jobs:
runner-job:
runs-on: ubuntu-latest
services:
postgres:
image: ghcr.io/orgname/reponame:tag
# add this to each service with an image from a private repo
credentials:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
此示例意味着您有两个 secrets:DOCKER_USER
和 DOCKER_PASSWORD
。