Open kponichtera opened 2 years ago
~I am having the exact same issue, I noticed the gha cache hash changes between re-runs of the same job (no git changes between each re-run)~
Okay, my issue was actually different, in my case I was adding ARGs before the steps I wanted to cache, and as one of these was changing every build, it was invalidating the cache of all future steps. Moving the ARG closer to the place where it is actually used solved it for me.
In my project I have configured Docker containers, which bundle all the application dependencies and are used locally by the developers to keep their local machines reasonably clean. I wanted to integrate these images into CI/CD to ensure maximum repeatability and avoid repeating myself when defining certain commands.
I have a custom action, which builds the "builder" image, defined as follows:
It creates the image in the scope of Buildx builder and then loads it into Github Action runner's Docker instance.
Then in my jobs I am using the built image to execute the command in the
The
build-push-action
seems to call the correct docker command, reads the GHA cache and pushes it after building all the layers:However, subsequent executions of the job on the same branch do not use this cache and rebuild all the layers
When I replace
load: true
withpush: true
and put the builder image into registry, the caching works as expected. However, it also pollutes my organization's package registry with unnecessary images.I didn't find any mention on why the caching shouldn't work when pushing is not enabled - is it by design or is this a bug?