gha: export cache to github even on build failure
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 10.3k
- Forks
- 1.5k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 48
Description
The experimental gha cache backend --cache-from: type=gha --cache-to: type=gha,mode=max works very well for me!
One use-case that I'd like it to have, is to trigger the cache upload even on failed builds.
I.e. I use the official docker/build-push-action@v5 github action.
I'm not sure what triggers the cache upload to gha but it only happens on successful builds. I'd love if there was an extra flag/setting to also trigger the upload on failure.
My current workaround is to manually manage the cache with type=local:
- name: Restore Cached Docker Layers
uses: actions/cache/restore@v3
with:
path: /tmp/.buildx-cache
key: ${{env.base_tag}}-buildx-
- name: Build and Push as Staging
uses: docker/build-push-action@v5
with:
context: ./${{matrix.image}}
push: true
tags: ${{env.base_tag}}:staging
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Move Docker Layers Cache
if: always()
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Save Docker Layers Cache
uses: actions/cache/save@v3
if: always()
with:
path: /tmp/.buildx-cache
key: ${{env.base_tag}}-buildx-${{github.sha}}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the experimental gha cache backend used by --cache-from: type=gha and --cache-to: type=gha,mode=max, then reproduce a failed build through docker/build-push-action@v5. Determine where cache upload is gated on build success. Done means an explicit setting causes the gha cache to upload usable layers after a failed build, without changing successful builds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, github-actions, go
- Domain
- build-system, ci-cd, devops
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100