feat: Improve cache hit on build
This commit is contained in:
18
.github/workflows/publish.yml
vendored
18
.github/workflows/publish.yml
vendored
@@ -18,7 +18,7 @@ on:
|
||||
env:
|
||||
IMAGE_NAME: cdalvaro/docker-salt-master
|
||||
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
|
||||
CACHE_PATH: /tmp/.buildx-docker-salt-master-cache
|
||||
CACHE_PATH: ${{ github.workspace }}/.buildx-cache
|
||||
EXTRA_REGISTRIES: ghcr.io quay.io
|
||||
|
||||
jobs:
|
||||
@@ -46,6 +46,7 @@ jobs:
|
||||
echo "Docker image: '${DOCKER_IMAGE}'"
|
||||
echo "Tags: ${TAGS}"
|
||||
|
||||
# FIXME: set-output is deprecated
|
||||
echo ::set-output name=tags::${TAGS}
|
||||
|
||||
- name: VCS ref
|
||||
@@ -53,6 +54,7 @@ jobs:
|
||||
run: |
|
||||
VCS_REF="${GITHUB_SHA::8}"
|
||||
echo "VCS ref: ${VCS_REF}"
|
||||
# FIXME: set-output is deprecated
|
||||
echo ::set-output name=vcs_ref::${VCS_REF}
|
||||
|
||||
- name: Created On
|
||||
@@ -60,6 +62,7 @@ jobs:
|
||||
run: |
|
||||
CREATED_ON="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
||||
echo "Created on: ${CREATED_ON}"
|
||||
# FIXME: set-output is deprecated
|
||||
echo ::set-output name=created_on::${CREATED_ON}
|
||||
|
||||
- name: Dump environment
|
||||
@@ -87,6 +90,7 @@ jobs:
|
||||
uses: docker/setup-buildx-action@v2.2.1
|
||||
|
||||
- name: Cache Docker layers
|
||||
id: cache-docker-layers
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ env.CACHE_PATH }}
|
||||
@@ -94,6 +98,17 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
- name: Cache hit
|
||||
continue-on-error: true
|
||||
env:
|
||||
CACHE_HIT: ${{ steps.cache-docker-layers.outputs.cache-hit }}
|
||||
run: |
|
||||
if [[ "${CACHE_HIT}" != 'true' ]]; then
|
||||
echo "No cache hit" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Cache contents available at: ${CACHE_PATH}"
|
||||
|
||||
- name: Login to Docker Container Registry
|
||||
uses: docker/login-action@v2.1.0
|
||||
with:
|
||||
@@ -127,5 +142,6 @@ jobs:
|
||||
type=local,src=${{ env.CACHE_PATH }}
|
||||
ghcr.io/cdalvaro/docker-salt-master:latest
|
||||
cache-to: type=local,dest=${{ env.CACHE_PATH }}
|
||||
pull: true
|
||||
push: true
|
||||
tags: ${{ needs.metadata.outputs.tags }}
|
||||
|
||||
Reference in New Issue
Block a user