nektos / act

Run your GitHub Actions locally 🚀
https://nektosact.com
MIT License
53.89k stars 1.34k forks source link

Docker gha cache exporter fails #1916

Open zacps opened 1 year ago

zacps commented 1 year ago

Bug report info

act version:            0.2.48
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 16
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
        /var/run/docker.sock
Config files:           
        /home/zac/.actrc:
                -P ubuntu-latest=catthehacker/ubuntu:act-latest
                -P ubuntu-22.04=catthehacker/ubuntu:act-22.04
                -P ubuntu-20.04=catthehacker/ubuntu:act-20.04
                -P ubuntu-18.04=catthehacker/ubuntu:act-18.04
Build info:
        Go version:            go1.18.10
        Module path:           github.com/nektos/act
        Main version:          (devel)
        Main path:             github.com/nektos/act
        Main checksum:         
        Build settings:
                -compiler:            gc
                -ldflags:             -s -w -X main.version=0.2.48 -X main.commit=3a0a6425a80f3405670d8d7b11ed18ea56a09af4 -X main.date=2023-07-10T20:04:04Z -X main.builtBy=goreleaser
                CGO_ENABLED:          0
                GOARCH:               amd64
                GOOS:                 linux
                GOAMD64:              v1
                vcs:                  git
                vcs.revision:         3a0a6425a80f3405670d8d7b11ed18ea56a09af4
                vcs.time:             2023-07-10T20:03:46Z
                vcs.modified:         false
Docker Engine:
        Engine version:        24.0.2
        Engine runtime:        runc
        Cgroup version:        2
        Cgroup driver:         systemd
        Storage driver:        overlay2
        Registry URI:          https://index.docker.io/v1/
        OS:                    Ubuntu 22.04.2 LTS
        OS type:               linux
        OS version:            22.04
        OS arch:               x86_64
        OS kernel:             5.19.0-46-generic
        OS CPU:                16
        OS memory:             31811 MB
        Security options:
                name=apparmor
                name=seccomp,profile=builtin
                name=cgroupns

Command used with act

act pull_request --pull=false -r -e event.json --artifact-server-path ~/.artifacts/

Describe issue

The gha cache style would either work or silently be ignored, instead the job fails if it is configured.

The other parts of the workflow file are sensitive.

Link to GitHub repository

No response

Workflow content

- name: Build
        uses: docker/build-push-action@v4
        with:
          context: "path/to/context"
          push: false
          cache-from: type=gha
          cache-to: type=gha,mode=max
          tags: "a-tag"
          outputs: type=docker,dest=/tmp/model-path
          ssh: default=${{ env.SSH_AUTH_SOCK }}

Relevant log output

[CI/build-1      ]   ❗  ::error::buildx failed with: ERROR: failed to solve: failed to configure gha cache exporter: token contains an invalid number of segments

Additional information

No response

JoshMcCullough commented 11 months ago

Same here. Is there a workaround?

JoshMcCullough commented 9 months ago

@zacps I finally got back on this project, where I was stuck with this issue and I resolved it as follows:

Add an input e.g. use-cache:

use-cache:
  type: boolean
  description: Whether or not to use the Docker action's cache feature.
  default: true

Optionally configure the cache options when calling the docker-build-push workflow:

with:
  cache-from: ${{ inputs.use-cache == 'true' && 'type=gha' || 'type=local,src=/tmp' }}
  cache-to: ${{ inputs.use-cache == 'true' && 'type=gha, mode=max' || 'type=local,dest=/tmp' }}

Make sure you pass the input forward from your test YAML!

github-actions[bot] commented 3 months ago

Issue is stale and will be closed in 14 days unless there is new activity

bennesp commented 3 months ago

This is not a valid solution to me, since it requires changing the workflow. Has anyone succeeded in having GHA Cache working in act?