feat: add cache-from upstream
Provides a quick start for new forks. PR: #64
This commit is contained in:
parent
f531452a17
commit
b551a568f5
9
.github/workflows/containers.yml
vendored
9
.github/workflows/containers.yml
vendored
@ -7,6 +7,7 @@ env:
|
|||||||
docker-hub-credentials: ${{ secrets.DOCKER_HUB_USERNAME != null && secrets.DOCKER_HUB_TOKEN != null }}
|
docker-hub-credentials: ${{ secrets.DOCKER_HUB_USERNAME != null && secrets.DOCKER_HUB_TOKEN != null }}
|
||||||
ghcr-credentials: ${{ secrets.GHCR_USERNAME != null && secrets.GHCR_TOKEN != null }}
|
ghcr-credentials: ${{ secrets.GHCR_USERNAME != null && secrets.GHCR_TOKEN != null }}
|
||||||
docker-hub-namespace: ${{ secrets.DOCKER_HUB_NAMESPACE || github.repository_owner }}
|
docker-hub-namespace: ${{ secrets.DOCKER_HUB_NAMESPACE || github.repository_owner }}
|
||||||
|
docker-hub-namespace-upstream: ${{ secrets.DOCKER_HUB_NAMESPACE_UPSTREAM || 'zmkfirmware' }}
|
||||||
ghcr-namespace: ${{ github.repository_owner }}
|
ghcr-namespace: ${{ github.repository_owner }}
|
||||||
zmk-repository: ${{ secrets.ZMK_REPOSITORY || 'zmkfirmware/zmk' }}
|
zmk-repository: ${{ secrets.ZMK_REPOSITORY || 'zmkfirmware/zmk' }}
|
||||||
zmk-ref: ${{ secrets.ZMK_REF || 'main' }}
|
zmk-ref: ${{ secrets.ZMK_REF || 'main' }}
|
||||||
@ -95,6 +96,7 @@ jobs:
|
|||||||
id: paths
|
id: paths
|
||||||
env:
|
env:
|
||||||
NS: ${{ env.docker-hub-namespace }}
|
NS: ${{ env.docker-hub-namespace }}
|
||||||
|
NSU: ${{ env.docker-hub-namespace-upstream }}
|
||||||
REPOSITORY: zmk-dev-generic-cache
|
REPOSITORY: zmk-dev-generic-cache
|
||||||
BRANCH: ${{ needs.tags.outputs.branch }}
|
BRANCH: ${{ needs.tags.outputs.branch }}
|
||||||
BASE: ${{ needs.tags.outputs.base }}
|
BASE: ${{ needs.tags.outputs.base }}
|
||||||
@ -105,6 +107,7 @@ jobs:
|
|||||||
if [ ! -z "$BASE" ]; then
|
if [ ! -z "$BASE" ]; then
|
||||||
echo ::set-output name=base::docker.io/${NS}/${REPOSITORY}:${BASE}
|
echo ::set-output name=base::docker.io/${NS}/${REPOSITORY}:${BASE}
|
||||||
fi
|
fi
|
||||||
|
echo ::set-output name=branch-upstream::docker.io/${NSU}/${REPOSITORY}:${BRANCH}
|
||||||
- name: Set up cache
|
- name: Set up cache
|
||||||
id: cache
|
id: cache
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
@ -132,6 +135,7 @@ jobs:
|
|||||||
cache-from: |
|
cache-from: |
|
||||||
type=registry,ref=${{ steps.paths.outputs.branch }}
|
type=registry,ref=${{ steps.paths.outputs.branch }}
|
||||||
${{ (steps.paths.outputs.base != '') && format('type=registry,ref={0}', steps.paths.outputs.base) || '' }}
|
${{ (steps.paths.outputs.base != '') && format('type=registry,ref={0}', steps.paths.outputs.base) || '' }}
|
||||||
|
type=registry,ref=${{ steps.paths.outputs.branch-upstream }}
|
||||||
cache-to: type=local,dest=${{ steps.paths.outputs.local-new }},mode=max
|
cache-to: type=local,dest=${{ steps.paths.outputs.local-new }},mode=max
|
||||||
- name: Push to registry cache
|
- name: Push to registry cache
|
||||||
if: ${{ (steps.should-rebuild.outputs.value == 'true') && (env.docker-hub-credentials == 'true') }}
|
if: ${{ (steps.should-rebuild.outputs.value == 'true') && (env.docker-hub-credentials == 'true') }}
|
||||||
@ -197,6 +201,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
NS: ${{ env.docker-hub-namespace }}
|
NS: ${{ env.docker-hub-namespace }}
|
||||||
|
NSU: ${{ env.docker-hub-namespace-upstream }}
|
||||||
BUILD: ${{ steps.repositories.outputs.build }}
|
BUILD: ${{ steps.repositories.outputs.build }}
|
||||||
DEV: ${{ steps.repositories.outputs.dev }}
|
DEV: ${{ steps.repositories.outputs.dev }}
|
||||||
CANDIDATE: ${{ needs.tags.outputs.candidate }}
|
CANDIDATE: ${{ needs.tags.outputs.candidate }}
|
||||||
@ -209,11 +214,13 @@ jobs:
|
|||||||
if [ ! -z "$BASE" ]; then
|
if [ ! -z "$BASE" ]; then
|
||||||
echo ::set-output name=build-base::docker.io/${NS}/${BUILD}:${BASE}
|
echo ::set-output name=build-base::docker.io/${NS}/${BUILD}:${BASE}
|
||||||
fi
|
fi
|
||||||
|
echo ::set-output name=build-branch-upstream::docker.io/${NSU}/${BUILD}:${BRANCH}
|
||||||
echo ::set-output name=dev-candidate::docker.io/${NS}/${DEV}:${CANDIDATE}
|
echo ::set-output name=dev-candidate::docker.io/${NS}/${DEV}:${CANDIDATE}
|
||||||
echo ::set-output name=dev-branch::docker.io/${NS}/${DEV}:${BRANCH}
|
echo ::set-output name=dev-branch::docker.io/${NS}/${DEV}:${BRANCH}
|
||||||
if [ ! -z "$BASE" ]; then
|
if [ ! -z "$BASE" ]; then
|
||||||
echo ::set-output name=dev-base::docker.io/${NS}/${DEV}:${BASE}
|
echo ::set-output name=dev-base::docker.io/${NS}/${DEV}:${BASE}
|
||||||
fi
|
fi
|
||||||
|
echo ::set-output name=dev-branch-upstream::docker.io/${NSU}/${DEV}:${BRANCH}
|
||||||
- name: Define build-args
|
- name: Define build-args
|
||||||
id: build-args
|
id: build-args
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -271,6 +278,7 @@ jobs:
|
|||||||
type=registry,ref=${{ steps.paths.outputs.build-candidate }}
|
type=registry,ref=${{ steps.paths.outputs.build-candidate }}
|
||||||
type=registry,ref=${{ steps.paths.outputs.build-branch }}
|
type=registry,ref=${{ steps.paths.outputs.build-branch }}
|
||||||
${{ (steps.paths.outputs.build-base != '') && format('type=registry,ref={0}', steps.paths.outputs.build-base) || '' }}
|
${{ (steps.paths.outputs.build-base != '') && format('type=registry,ref={0}', steps.paths.outputs.build-base) || '' }}
|
||||||
|
type=registry,ref=${{ steps.paths.outputs.build-branch-upstream }}
|
||||||
cache-to: type=inline
|
cache-to: type=inline
|
||||||
load: true
|
load: true
|
||||||
- name: Build and load 'dev' candidate image
|
- name: Build and load 'dev' candidate image
|
||||||
@ -290,6 +298,7 @@ jobs:
|
|||||||
type=registry,ref=${{ steps.paths.outputs.dev-candidate }}
|
type=registry,ref=${{ steps.paths.outputs.dev-candidate }}
|
||||||
type=registry,ref=${{ steps.paths.outputs.dev-branch }}
|
type=registry,ref=${{ steps.paths.outputs.dev-branch }}
|
||||||
${{ (steps.paths.outputs.dev-base != '') && format('type=registry,ref={0}', steps.paths.outputs.dev-base) || '' }}
|
${{ (steps.paths.outputs.dev-base != '') && format('type=registry,ref={0}', steps.paths.outputs.dev-base) || '' }}
|
||||||
|
type=registry,ref=${{ steps.paths.outputs.dev-branch-upstream }}
|
||||||
cache-to: type=inline
|
cache-to: type=inline
|
||||||
load: true
|
load: true
|
||||||
- name: Checkout ZMK
|
- name: Checkout ZMK
|
||||||
|
Loading…
Reference in New Issue
Block a user