diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index 3e37481..09a6394 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -88,6 +88,7 @@ jobs: echo ::set-output name=major-minor-branch::${MAJOR_MINOR_BRANCH} dev-generic: needs: + - timestamp - tags if: ${{ !startsWith(github.ref, 'refs/tags') }} runs-on: ubuntu-latest @@ -133,18 +134,14 @@ jobs: cache-name: dev-generic with: path: ${{ steps.paths.outputs.local }} - key: ${{ runner.os }}/${{ env.cache-name }}/${{ github.run_id }} - - name: Rebuild cache? - id: should-rebuild - run: echo ::set-output name=value::${{ steps.cache.outputs.cache-hit != 'true' || env.no-cache == 'true' }} + key: ${{ runner.os }}/${{ env.cache-name }}/${{ github.run_id }}/${{ needs.timestamp.outputs.timestamp }} + restore-keys: | + ${{ runner.os }}/${{ env.cache-name }}/${{ github.run_id }} - name: Set up QEMU - if: ${{ steps.should-rebuild.outputs.value == 'true' }} uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx - if: ${{ steps.should-rebuild.outputs.value == 'true' }} uses: docker/setup-buildx-action@v1 - name: Build to local cache - if: ${{ steps.should-rebuild.outputs.value == 'true' }} uses: docker/build-push-action@v2 with: target: dev-generic @@ -152,6 +149,7 @@ jobs: ZEPHYR_VERSION=${{ env.zephyr-version }} no-cache: ${{ env.no-cache == 'true' }} cache-from: | + type=local,src=${{ steps.paths.outputs.local }} 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 }} @@ -159,7 +157,7 @@ jobs: 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') }} + if: ${{ env.docker-hub-credentials == 'true' }} uses: docker/build-push-action@v2 with: target: dev-generic @@ -174,12 +172,12 @@ jobs: # https://github.com/docker/build-push-action/issues/252 # https://github.com/moby/buildkit/issues/1896 - name: Switch local cache - if: ${{ steps.should-rebuild.outputs.value == 'true' }} run: | rm -rf ${{ steps.paths.outputs.local }} mv ${{ steps.paths.outputs.local-new }} ${{ steps.paths.outputs.local }} candidates: needs: + - timestamp - architectures - tags - dev-generic @@ -286,7 +284,7 @@ jobs: cache-name: dev-generic with: path: ${{ steps.paths.outputs.dev-generic }} - key: ${{ runner.os }}/${{ env.cache-name }}/${{ github.run_id }} + key: ${{ runner.os }}/${{ env.cache-name }}/${{ github.run_id }}/${{ needs.timestamp.outputs.timestamp }} - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx