From 88620c678ee31eb814b59da9222049eb9d5b4b04 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Thu, 10 Jun 2021 14:12:18 +0100 Subject: [PATCH] feat: add cache-from major-minor-branch Lets any branch utilize its corresponding major-minor-branch cache. See: #62 PR: #68 --- .github/workflows/containers.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index 0800218..0e30ef1 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -43,6 +43,7 @@ jobs: candidate: ${{ steps.definitions.outputs.candidate }} versions: ${{ steps.definitions.outputs.versions }} major-minor: ${{ steps.definitions.outputs.major-minor }} + major-minor-branch: ${{ steps.definitions.outputs.major-minor-branch }} latest: ${{ steps.definitions.outputs.latest }} release-trigger: ${{ steps.definitions.outputs.release-trigger }} steps: @@ -61,6 +62,7 @@ jobs: MAJOR=$(echo ${ZEPHYR_VERSION} | cut -d'.' -f 1) MINOR=$(echo ${ZEPHYR_VERSION} | cut -d'.' -f 2) MAJOR_MINOR=${MAJOR}.${MINOR} + MAJOR_MINOR_BRANCH=${MAJOR_MINOR}-branch LATEST=${MAJOR_MINOR} RELEASE_TRIGGER=${ZEPHYR_VERSION}-${ZEPHYR_SDK_VERSION} @@ -69,6 +71,7 @@ jobs: echo ::set-output name=candidate::${CANDIDATE} echo ::set-output name=versions::${VERSIONS} echo ::set-output name=major-minor::${MAJOR_MINOR} + echo ::set-output name=major-minor-branch::${MAJOR_MINOR_BRANCH} echo ::set-output name=latest::${LATEST} echo ::set-output name=release-trigger::${RELEASE_TRIGGER} dev-generic: @@ -100,6 +103,7 @@ jobs: REPOSITORY: zmk-dev-generic-cache BRANCH: ${{ needs.tags.outputs.branch }} BASE: ${{ needs.tags.outputs.base }} + MAJOR_MINOR_BRANCH: ${{ needs.tags.outputs.major-minor-branch }} run: | echo ::set-output name=local::/tmp/.buildx/dev-generic echo ::set-output name=local-new::/tmp/.buildx/dev-generic-new @@ -107,7 +111,9 @@ jobs: if [ ! -z "$BASE" ]; then echo ::set-output name=base::docker.io/${NS}/${REPOSITORY}:${BASE} fi + echo ::set-output name=major-minor-branch::docker.io/${NS}/${REPOSITORY}:${MAJOR_MINOR_BRANCH} echo ::set-output name=branch-upstream::docker.io/${NSU}/${REPOSITORY}:${BRANCH} + echo ::set-output name=major-minor-branch-upstream::docker.io/${NSU}/${REPOSITORY}:${MAJOR_MINOR_BRANCH} - name: Set up cache id: cache uses: actions/cache@v2 @@ -135,7 +141,9 @@ jobs: cache-from: | type=registry,ref=${{ steps.paths.outputs.branch }} ${{ (steps.paths.outputs.base != '') && format('type=registry,ref={0}', steps.paths.outputs.base) || '' }} + type=registry,ref=${{ steps.paths.outputs.major-minor-branch }} type=registry,ref=${{ steps.paths.outputs.branch-upstream }} + type=registry,ref=${{ steps.paths.outputs.major-minor-branch-upstream }} cache-to: type=local,dest=${{ steps.paths.outputs.local-new }},mode=max - name: Push to registry cache if: ${{ (steps.should-rebuild.outputs.value == 'true') && (env.docker-hub-credentials == 'true') }} @@ -207,6 +215,7 @@ jobs: CANDIDATE: ${{ needs.tags.outputs.candidate }} BRANCH: ${{ needs.tags.outputs.branch }} BASE: ${{ needs.tags.outputs.base }} + MAJOR_MINOR_BRANCH: ${{ needs.tags.outputs.major-minor-branch }} run: | echo ::set-output name=dev-generic::/tmp/.buildx/dev-generic echo ::set-output name=build-candidate::docker.io/${NS}/${BUILD}:${CANDIDATE} @@ -214,13 +223,17 @@ jobs: if [ ! -z "$BASE" ]; then echo ::set-output name=build-base::docker.io/${NS}/${BUILD}:${BASE} fi + echo ::set-output name=build-major-minor-branch::docker.io/${NS}/${BUILD}:${MAJOR_MINOR_BRANCH} echo ::set-output name=build-branch-upstream::docker.io/${NSU}/${BUILD}:${BRANCH} + echo ::set-output name=build-major-minor-branch-upstream::docker.io/${NSU}/${BUILD}:${MAJOR_MINOR_BRANCH} echo ::set-output name=dev-candidate::docker.io/${NS}/${DEV}:${CANDIDATE} echo ::set-output name=dev-branch::docker.io/${NS}/${DEV}:${BRANCH} if [ ! -z "$BASE" ]; then echo ::set-output name=dev-base::docker.io/${NS}/${DEV}:${BASE} fi + echo ::set-output name=dev-major-minor-branch::docker.io/${NS}/${DEV}:${MAJOR_MINOR_BRANCH} echo ::set-output name=dev-branch-upstream::docker.io/${NSU}/${DEV}:${BRANCH} + echo ::set-output name=dev-major-minor-branch-upstream::docker.io/${NSU}/${DEV}:${MAJOR_MINOR_BRANCH} - name: Define build-args id: build-args shell: bash @@ -278,7 +291,9 @@ jobs: type=registry,ref=${{ steps.paths.outputs.build-candidate }} type=registry,ref=${{ steps.paths.outputs.build-branch }} ${{ (steps.paths.outputs.build-base != '') && format('type=registry,ref={0}', steps.paths.outputs.build-base) || '' }} + type=registry,ref=${{ steps.paths.outputs.build-major-minor-branch }} type=registry,ref=${{ steps.paths.outputs.build-branch-upstream }} + type=registry,ref=${{ steps.paths.outputs.build-major-minor-branch-upstream }} cache-to: type=inline load: true - name: Build and load 'dev' candidate image @@ -298,7 +313,9 @@ jobs: type=registry,ref=${{ steps.paths.outputs.dev-candidate }} type=registry,ref=${{ steps.paths.outputs.dev-branch }} ${{ (steps.paths.outputs.dev-base != '') && format('type=registry,ref={0}', steps.paths.outputs.dev-base) || '' }} + type=registry,ref=${{ steps.paths.outputs.dev-major-minor-branch }} type=registry,ref=${{ steps.paths.outputs.dev-branch-upstream }} + type=registry,ref=${{ steps.paths.outputs.dev-major-minor-branch-upstream }} cache-to: type=inline load: true - name: Checkout ZMK