docker / build-push-action

GitHub Action to build and push Docker images with Buildx
https://github.com/marketplace/actions/build-and-push-docker-images
Apache License 2.0
4.11k stars 527 forks source link

insufficient_scope: authorization failed #987

Closed Yucked closed 9 months ago

Yucked commented 9 months ago

Contributing guidelines

I've found a bug, and:

Description

Error when pushing to ghcr.io, workflow is as follow:

   publish:
    name: Publish to GitHub
    runs-on: ubuntu-latest
    needs: build

    steps:
    - name: Checkout
      uses: actions/checkout@v4

    - name: Docker Login      
      uses: docker/login-action@v3
      with:
        registry: ghcr.io
        username: ${{ github.repository_owner }}
        password: ${{ secrets.GITHUB_TOKEN }}

    - name: Build and push Docker images
      uses: docker/build-push-action@v5
      with: 
        pull: true
        context: .
        push: true
        tags: ghcr.io/yucked/grimoire:${{ github.run_number }}  

Already tried the suggestions in #160

#3 [internal] load metadata for docker.io/library/build:latest
#3 ERROR: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
------
 > [internal] load metadata for docker.io/library/build:latest:
------
Dockerfile:4
--------------------
   2 |     RUN apk add --no-cache curl unzip
   3 |     
   4 | >>> FROM build
   5 |     RUN curl -OJL https://github.com/Yucked/Grimoire/archive/refs/heads/main.zip && \
   6 |         unzip '*.zip' && \
--------------------
ERROR: failed to solve: build: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
Error: buildx failed with: ERROR: failed to solve: build: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

Expected behaviour

Should be able to build the image

Actual behaviour

Fails to build the image and push to github registry

Error: buildx failed with: ERROR: failed to solve: build: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

Repository URL

https://github.com/Yucked/Grimoire

Workflow run URL

https://github.com/Yucked/Grimoire/actions/runs/6486766699/job/17615641628

YAML workflow

name: Build & Publish
on: push

jobs:
   build:
    name: Build
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v4

    - name: Setup .NET Core SDK
      uses: actions/setup-dotnet@v3.2.0
      with:
        dotnet-version: 8.x

   publish:
    name: Publish to GitHub
    runs-on: ubuntu-latest
    needs: build

    steps:
    - name: Checkout
      uses: actions/checkout@v4

    - name: Docker Login      
      uses: docker/login-action@v3
      with:
        registry: ghcr.io
        username: ${{ github.repository_owner }}
        password: ${{ secrets.GITHUB_TOKEN }}

    - name: Build and push Docker images
      uses: docker/build-push-action@v5
      with: 
        pull: true
        context: .
        push: true
        tags: ghcr.io/yucked/grimoire:${{ github.run_number }}

Workflow logs

No response

BuildKit logs

No response

Additional info

No response

crazy-max commented 9 months ago

The error looks legit looking at your Dockerfile: https://github.com/Yucked/Grimoire/blob/79f25660b52231ff0227c08d7f67068bab46c01e/Dockerfile#L4

FROM mcr.microsoft.com/dotnet/sdk:8.0
RUN apk add --no-cache curl unzip

FROM build
RUN curl -OJL https://github.com/Yucked/Grimoire/archive/refs/heads/main.zip && \
    unzip '*.zip' && \
    mkdir app && mv Grimoire-main/* app/ && \
    rm *.zip  && rm -rf Grimoire-main

WORKDIR app
RUN dotnet restore && \
    dotnet publish -c Release -o out

WORKDIR out
ENTRYPOINT ["dotnet", "Grimoire.Web.dll"]

build image does not exist. I also repro locally with a simple docker build .

Maybe you just need to remove the line FROM build, I'm not sure.

Closing as it does not seem to be an issue with the action but your Dockerfile.

aryangosling commented 4 months ago

how did you solve it @Yucked ?

Yucked commented 4 months ago

@aryangosling I overlooked the 2nd "FROM build" line 4.