我正在尝试将Docker镜像从GitHub Actions工作流中推送到GitHub容器注册表(ghcr.io)。以下是我采取的步骤:
1.创建具有包读/写/删除权限的GitHub个人访问令牌(PAT)
1.在本地通过此PAT登录
export CR_PAT='...'
echo $CR_PAT| docker login ghcr.io -u <MY GITHUB USERNAME> --password-stdin
1.我用正确的标签标记了我的Docker镜像并推送到ghcr
docker tag texlive ghcr.io/michaellihs/texlive:latest
docker push ghcr.io/michaellihs/texlive:latest
1.图像已成功推送到https://github.com/users/michaellihs/packages/container/texlive
1.我转到https://github.com/users/michaellihs/packages/container/texlive/settings
包的设置页面,并将我实现GitHub Actions工作流(https://github.com/michaellihs/docker-texlive
)的存储库添加为Actions Access,角色为admin
1.我使用以下GitHub操作工作流来构建和推送我的图像
name: ci
on:
push:
branches:
- 'main'
using-an-action
jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: https://ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: image/
push: true
tags: ghcr.io/michaellihs/texlive:latest
1.当我现在运行workflow时,我得到以下错误:
#10 ERROR: denied: installation not allowed to Write organization package
------
> pushing ghcr.io/michaellihs/texlive:latest with docker:
------
ERROR: denied: installation not allowed to Write organization package
Error: buildx call failed with: ERROR: denied: installation not allowed to Write
organization package
1条答案
按热度按时间balp4ylt1#
好像还差一步:在托管工作流的存储库中,
1.转到存储库设置(
/settings
)1.从菜单中选择“操作--〉常规”
1.在“工作流权限”中选择“读写权限”
之后别忘了点击“保存”
这解决了问题,并成功地将图像推送到注册表。