I’m trying to create a Github Action workflow to build a Docker image, then unless all layers use cache (no rebuild), continue to push the result and cache.
With this workflow it always pushes the result and cache.
on: [push]
jobs:
build:
permissions:
packages: write
runs-on: ubuntu-latest
steps:
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
password: ${{ secrets.GITHUB_TOKEN }}
username: ${{ github.repository_owner }}
- uses: docker/build-push-action@v6
with:
push: true
tags: ghcr.io/<user>/<name>
cache-from: type=registry,ref=ghcr.io/<user>/<name>:build-cache
cache-to: type=registry,ref=ghcr.io/<user>/<name>:build-cache
How to make docker pushes the build result and cache unless all layers use cache?
I can’t find a way to add such check into docker/build-push-action@v6
. My approach is remove push
and cache-to
from the action, and manually push after checking the image id with docker image ls -q -f=reference=ghcr.io/<user>/<name>
but not sure about detailed steps.
kinoubenkyou is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.