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:
|
env:
|
||||||
IMAGE_NAME: cdalvaro/docker-salt-master
|
IMAGE_NAME: cdalvaro/docker-salt-master
|
||||||
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
|
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
|
EXTRA_REGISTRIES: ghcr.io quay.io
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -46,6 +46,7 @@ jobs:
|
|||||||
echo "Docker image: '${DOCKER_IMAGE}'"
|
echo "Docker image: '${DOCKER_IMAGE}'"
|
||||||
echo "Tags: ${TAGS}"
|
echo "Tags: ${TAGS}"
|
||||||
|
|
||||||
|
# FIXME: set-output is deprecated
|
||||||
echo ::set-output name=tags::${TAGS}
|
echo ::set-output name=tags::${TAGS}
|
||||||
|
|
||||||
- name: VCS ref
|
- name: VCS ref
|
||||||
@@ -53,6 +54,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
VCS_REF="${GITHUB_SHA::8}"
|
VCS_REF="${GITHUB_SHA::8}"
|
||||||
echo "VCS ref: ${VCS_REF}"
|
echo "VCS ref: ${VCS_REF}"
|
||||||
|
# FIXME: set-output is deprecated
|
||||||
echo ::set-output name=vcs_ref::${VCS_REF}
|
echo ::set-output name=vcs_ref::${VCS_REF}
|
||||||
|
|
||||||
- name: Created On
|
- name: Created On
|
||||||
@@ -60,6 +62,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
CREATED_ON="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
CREATED_ON="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
||||||
echo "Created on: ${CREATED_ON}"
|
echo "Created on: ${CREATED_ON}"
|
||||||
|
# FIXME: set-output is deprecated
|
||||||
echo ::set-output name=created_on::${CREATED_ON}
|
echo ::set-output name=created_on::${CREATED_ON}
|
||||||
|
|
||||||
- name: Dump environment
|
- name: Dump environment
|
||||||
@@ -87,6 +90,7 @@ jobs:
|
|||||||
uses: docker/setup-buildx-action@v2.2.1
|
uses: docker/setup-buildx-action@v2.2.1
|
||||||
|
|
||||||
- name: Cache Docker layers
|
- name: Cache Docker layers
|
||||||
|
id: cache-docker-layers
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ env.CACHE_PATH }}
|
path: ${{ env.CACHE_PATH }}
|
||||||
@@ -94,6 +98,17 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-buildx-
|
${{ 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
|
- name: Login to Docker Container Registry
|
||||||
uses: docker/login-action@v2.1.0
|
uses: docker/login-action@v2.1.0
|
||||||
with:
|
with:
|
||||||
@@ -127,5 +142,6 @@ jobs:
|
|||||||
type=local,src=${{ env.CACHE_PATH }}
|
type=local,src=${{ env.CACHE_PATH }}
|
||||||
ghcr.io/cdalvaro/docker-salt-master:latest
|
ghcr.io/cdalvaro/docker-salt-master:latest
|
||||||
cache-to: type=local,dest=${{ env.CACHE_PATH }}
|
cache-to: type=local,dest=${{ env.CACHE_PATH }}
|
||||||
|
pull: true
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ needs.metadata.outputs.tags }}
|
tags: ${{ needs.metadata.outputs.tags }}
|
||||||
|
|||||||
Reference in New Issue
Block a user