Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unknown cache exporter #306

Open
3 tasks done
cortopy opened this issue Mar 2, 2025 · 2 comments
Open
3 tasks done

unknown cache exporter #306

cortopy opened this issue Mar 2, 2025 · 2 comments

Comments

@cortopy
Copy link

cortopy commented Mar 2, 2025

Contributing guidelines

I've found a bug, and:

  • The documentation does not mention anything about my problem
  • There are no open or closed issues that are related to my problem

Description

I'm running bake-action like this:

     - name: Build and push
        uses: docker/bake-action@v6
        env:
          versions_string: ${{ steps.short-sha.outputs.sha }},latest
        with:
          push: true
          files: |
            ./${{ matrix.package.directory }}/docker-bake.hcl
          set: |
            *.cache-from="type=gha"
            *.cache-to="type=gha,mode=max"

and I'm getting error:

ERROR: failed to solve: unknown cache exporter: "gha,mode=max"

I've searched for other issues in the repo, and my configuration matches what others have said in the past should work I think

Expected behaviour

Action uses gha docker cache

Actual behaviour

Image doesn't build due to error

Repository URL

No response

Workflow run URL

No response

YAML workflow

name: Development Build

on:
  push:
    branches:
      - development

jobs:
  determine-apps-affected:
    # ....
          

  build_image:
    runs-on: ubuntu-22.04
    needs: [determine-apps-affected]
    strategy:
      matrix:
        package: ${{ fromJson(needs.determine-apps-affected.outputs.matrix) }}
    steps:
      - uses: benjlevesque/short-sha@v3.0
        id: short-sha
        with:
          length: 6

      - name: Login to container registry
        uses: docker/login-action@v3
        with:
          registry: ${{ VARS.CONTAINER_REGISTRY }}
          username: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
          password: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Build and push
        uses: docker/bake-action@v6
        env:
          versions_string: ${{ steps.short-sha.outputs.sha }},latest
        with:
          push: true
          files: |
            ./${{ matrix.package.directory }}/docker-bake.hcl
          set: |
            *.cache-from="type=gha"
            *.cache-to="type=gha,mode=max"

Workflow logs

No response

BuildKit logs


Additional info

No response

@crazy-max
Copy link
Member

This syntax looks correct:

          set: |
            *.cache-from="type=gha"
            *.cache-to="type=gha,mode=max"

But it should be:

          set: |
            *.cache-from=type=gha
            *.cache-to=type=gha,mode=max

I wonder if csv-parse library has an issue parsing with quotes.

Can you show the full logs of the Build and push step please?

@crazy-max
Copy link
Member

Ok I tried on my side and it gives:

Image

/usr/bin/docker buildx bake https://github.com/docker/test-docker-action.git#032e801d9756d88af32f1c3acceea67f3446c6cf --allow fs=* --set *.cache-from="type=gha" --set *.cache-to="type=gha,mode=max" --metadata-file /home/runner/work/_temp/docker-actions-toolkit-yWiaQB/bake-metadata-e1910d2271.json --provenance mode=min,inline-only=true,builder-id=https://github.com/docker/test-docker-action/actions/runs/13720577244/attempts/1 image --print
  {
    "group": {
      "default": {
        "targets": [
          "image"
        ]
      }
    },
    "target": {
      "image": {
        "attest": [
          {
            "builder-id": "https://github.com/docker/test-docker-action/actions/runs/13720577244/attempts/1",
            "inline-only": "true",
            "mode": "min",
            "type": "provenance"
          }
        ],
        "context": "https://github.com/docker/test-docker-action.git#032e801d9756d88af32f1c3acceea67f3446c6cf",
        "dockerfile": "./multistage.Dockerfile",
        "cache-from": [
          {
            "type": "gha"
          }
        ],
        "cache-to": [
          {
            "type": "gha,mode=max"
          }
        ],
        "platforms": [
          "linux/amd64",
          "linux/arm64"
        ]
      }
    }
  }

This is wrong though:

        "cache-to": [
          {
            "type": "gha,mode=max"
          }
        ],

I tried locally with:

docker buildx bake --set *.cache-to="type=gha,mode=max" --print

But works fine:

      "cache-to": [
        {
          "mode": "max",
          "type": "gha"
        }
      ],

So I wonder if this has something to do with args passed to exec in GitHub's toolkit: https://github.com/actions/toolkit/blob/dc22dc7cad322ab3cf9280133face378c63195f7/packages/exec/src/exec.ts#L17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants