Error: buildx failed with: ERROR: failed to solve: failed to push ghcr.io/: unexpected status: 403 Forbidden

huangapple go评论78阅读模式
英文:

Error: buildx failed with: ERROR: failed to solve: failed to push ghcr.io/: unexpected status: 403 Forbidden

问题

我正在使用GitHub Actions来构建和推送一个简单的Docker镜像到GitHub容器注册表。我的存储库位于一个组织中,并且我已经在组织级别配置了机密。

作业在登录到ghcr时成功,但在尝试将其推送到ghcr时出现以下错误:

错误:buildx失败,错误为:ERROR: failed to solve: failed to push ghcr.io/: unexpected status: 403 Forbidden.

github-actions.yml

name: 构建并推送Freeradius代理
on:
  push:
    branches:
      - '*'
jobs:
  build-and-push:
    runs-on: ubuntu-latest
    permissions:
      packages: write
    steps:
      - name: 检出代码
        uses: actions/checkout@v2
        with:
          token: ${{ secrets.GCR_TOKEN }}
      - name: 设置Docker Buildx
        uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
      - name: 登录到GHCR
        uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
        with:
          registry: ghcr.io
          username: ${{ secrets.REPO_OWNER }}
          password: ${{ secrets.GCR_TOKEN }}
      - name: 构建并推送Docker镜像
        uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
        with:
          context: .
          push: true
          tags: ghcr.io/${{ github.repository }}:${{ github.sha }}

我尝试使用不同版本的docker/setup-buildx-action,但它没有起作用!

英文:

I am using GitHub Actions, for building and pushing a simple docker image to GitHub Container registry. My repository is inside an organization and I have configured secrets on organization level.

The job succeeds in logging in to ghcr, but when it tries to push it to ghcr it end with the following error:

> Error: buildx failed with: ERROR: failed to solve: failed to push ghcr.io/: unexpected status: 403 Forbidden.

github-actions.yml

name: Build and Push Freeradius proxy
on:
  push:
    branches:
      - '*'
jobs:
  build-and-push:
    runs-on: ubuntu-latest
    permissions:
      packages: write
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2
        with:
          token: ${{ secrets.GCR_TOKEN}}
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
      - name: Login to GHCR
        uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
        with:
          registry: ghcr.io
          username: ${{ secrets.REPO_OWNER }}
          password: ${{ secrets.GCR_TOKEN }}
      - name: Build and Push Docker Image
        uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
        with:
          context: .
          push: true
          tags: ghcr.io/${{ github.repository }}:${{ github.sha }}

I tried using different versions of docker/setup-buildx-action but it didn't worked!

答案1

得分: 1

也许您的存储库操作没有设置为读写权限
Error: buildx failed with: ERROR: failed to solve: failed to push ghcr.io/: unexpected status: 403 Forbidden

英文:

Maybe your repository action is not setting in read and write permissions
Error: buildx failed with: ERROR: failed to solve: failed to push ghcr.io/: unexpected status: 403 Forbidden

huangapple
  • 本文由 发表于 2023年3月31日 17:50:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/75897093.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定