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.13k stars 532 forks source link

What is the cache ttl for type=gha ? #942

Closed mvynhb closed 10 months ago

mvynhb commented 10 months ago

Contributing guidelines

I've found a bug, and:

Description

Hi I am using the below configuration in my github actions:

    - name: Build and cache
      uses: docker/build-push-action@v4
      with:
        context: .
        push: true
        tags: localhost:5000/my-app/app:latest
        cache-from: type=gha
        cache-to: type=gha,mode=min

Its working as expected, the first run it builds my Dockerfile and the second run it uses the cache. However I have noticed that after 1 day or so the cache is not used anymore and needs to run the build again.

I read the ttl for cache entries on github action is 1 week https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy. Is there some setting I need to use to specify the ttl?

Thanks

Expected behaviour

Cache is re-used.

Actual behaviour

Cache is not re-used after about 1 day.

Repository URL

No response

Workflow run URL

No response

YAML workflow

- name: Build and cache
      uses: docker/build-push-action@v4
      with:
        context: .
        push: true
        tags: localhost:5000/my-app/app:latest
        cache-from: type=gha
        cache-to: type=gha,mode=min


### Workflow logs

_No response_

### BuildKit logs

_No response_

### Additional info

_No response_
crazy-max commented 10 months ago

I read the ttl for cache entries on github action is 1 week https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy. Is there some setting I need to use to specify the ttl?

I don't think there is a way to set a custom TTL with current GitHub API atm.

See also https://github.com/actions/cache/issues/780