Open tropxy opened 2 years ago
hmmm that seems to be about building caching and running an image, i'm not sure if it applies to pulling, caching and running an image.
is your use case caching within one workflow or across workflow? i've heard across workflow is like not possible
I found a simple way to use caches on this action, so share it here.
The solution is to set the load
option to true and specify a kind of cache by cache-from
and cache-to
when building a container with caches.
The load
lets docker load container images built from caches to docker images
. (docker buildx build | Docker Documentation)
Without setting the load
, docker can't find the cached container image when trying to run a container.
An example to use caches via GitHub Cache API:
- uses: docker/setup-buildx-action@v2
- uses: docker/build-push-action@v3
with:
tags: test-image:latest
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- uses: addnab/docker-run-action@v3
with:
image: test-image:latest
run: echo "hello world"
Notices:
docker/build-push-action
. However, I think it is the clearest way to use GitHub Actions Cache.Thanks @envzhu — this was v helpful
Hi, thanks for your great work on this, very helpful!
I was wondering what would be the best strategy to cache the docker image used by this action...would it be something related with using the cache action https://github.com/actions/cache? but how should we use it in combination with your action?
I also checked this thread: https://stackoverflow.com/questions/66421411/how-to-run-cached-docker-image-in-github-action, which gives a glimpse but I suppose your action would need to be modified for this...