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.1k stars 525 forks source link

v6 cannot be used with actions/download-artifact@v4 #1167

Open kateinoigakukun opened 1 day ago

kateinoigakukun commented 1 day ago

Contributing guidelines

I've found a bug, and:

Description

After updating docker/build-push-action to v6, we started observing the following error at actions/download-artifact step.

Unable to download artifact(s): Unable to download and extract artifact: Artifact download failed after 5 retries.

I guess something in the build summary uploading feature is incompatible with actions/download-artifact.

You can reproduce the problem with this https://github.com/kateinoigakukun/gh-actions-sandbox/actions/runs/9737812232/workflow

Expected behaviour

actions/download-artifact can download all artifacts even with this action.

Actual behaviour

actions/download-artifact fails while trying to download all artifacts

Repository URL

No response

Workflow run URL

No response

YAML workflow

name: Docker Build

on:
  workflow_dispatch:

jobs:
  docker:
    runs-on: ubuntu-latest
    steps:
      - uses: docker/build-push-action@v6
  post-job:
    runs-on: ubuntu-latest
    needs: [docker]
    steps:
      - uses: actions/download-artifact@v4

Workflow logs

No response

BuildKit logs

No response

Additional info

No response

crazy-max commented 1 day ago

Thanks for your feedback, looking at the workflow:

name: Docker Build

on:
  workflow_dispatch:

jobs:
  docker:
    runs-on: ubuntu-latest
    steps:
      - uses: docker/build-push-action@v6
  post-job:
    runs-on: ubuntu-latest
    needs: [docker]
    steps:
      - uses: actions/download-artifact@v4

It seems actions/download-artifact@v4 downloads all available artifacts within the workflow if name and pattern are not set: https://github.com/actions/download-artifact?tab=readme-ov-file#download-all-artifacts

If the name input parameter is not provided, all artifacts will be downloaded. To differentiate between downloaded artifacts, by default a directory denoted by the artifacts name will be created for each individual artifact. This behavior can be changed with the merge-multiple input parameter.

And will therefore try to download the .dockerbuild file uploaded by our action: https://github.com/kateinoigakukun/gh-actions-sandbox/actions/runs/9737812232/job/26870430716#step:2:13

Starting download of artifact to: /home/runner/work/gh-actions-sandbox/gh-actions-sandbox/kateinoigakukun~gh-actions-sandbox~8P1DEG.dockerbuild

I wonder if this is because we are setting the content disposition header when uploading the file to the store: https://github.com/docker/actions-toolkit/blob/fe9937dd36b64d2090fbfec40e144944ae390a12/src/github.ts#L159

I will take a closer look.

crazy-max commented 1 day ago

After enabling debug it seems it fails because the file is not a valid zip which makes sense because in your case it's a gzip:

##[debug]Failed to download artifact after 1 retries due to Not a valid zip file. Retrying in 5 seconds...
##[debug]Failed to download artifact after 2 retries due to Not a valid zip file. Retrying in 5 seconds...
##[debug]Failed to download artifact after 3 retries due to Not a valid zip file. Retrying in 5 seconds...
##[debug]Failed to download artifact after 4 retries due to Not a valid zip file. Retrying in 5 seconds...
##[debug]Failed to download artifact after 5 retries due to Not a valid zip file. Retrying in 5 seconds...
Error: Unable to download artifact(s): Unable to download and extract artifact: Artifact download failed after 5 retries.

Seems related to https://github.com/actions/download-artifact/issues/328

crazy-max commented 1 day ago

Found a way to mitigate this issue when using actions/download-artifact: https://github.com/actions/download-artifact/issues/328#issuecomment-2199704064

Will see for maintainers feedback.

hegerdes commented 1 day ago

Had the same issue.

If you remove the build summary artifacts it works again. I think you can disable it with setting DOCKER_BUILD_NO_SUMMARY=true