diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 42cd350..f7c8237 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,8 +10,18 @@ name: CI - master jobs: + setup: + runs-on: ubuntu-latest + outputs: + week: ${{ steps.date.outputs.week }} + steps: + - name: Get current date + id: date + run: echo "week=$(date +'%Y-%U')" >> "$GITHUB_OUTPUT" + build: runs-on: ubuntu-latest + needs: [setup] permissions: contents: read strategy: @@ -20,6 +30,8 @@ jobs: - arch: armv6l - arch: aarch64 - arch: x86_64 + env: + CACHE_KEY: build-${{ matrix.arch }}-${{ needs.setup.outputs.week }} steps: - name: Checkout @@ -47,8 +59,8 @@ jobs: build-args: | ARCH=${{ matrix.arch }} outputs: type=local,dest=dist - cache-from: type=gha,scope=build-${{ matrix.arch }} - cache-to: type=gha,mode=max,scope=build-${{ matrix.arch }} + cache-from: type=gha,scope=${{ env.CACHE_KEY }} + cache-to: type=gha,mode=max,scope=${{ env.CACHE_KEY }} - name: Upload artifact id: upload-initramfs @@ -73,7 +85,7 @@ jobs: INSTALL_PACKAGES=xbps-triggers dropbear pam sudo ROOTFS=extrarootfs outputs: type=local,dest=dist-extra - cache-from: type=gha,scope=build-${{ matrix.arch }} + cache-from: type=gha,scope=${{ env.CACHE_KEY }} cache-to: "" # don't write to cache for the extra initramfs - name: Upload extra initramfs artifact @@ -167,7 +179,7 @@ jobs: publish: runs-on: ubuntu-latest - needs: [test] + needs: [test, setup] if: github.event_name == 'push' && github.ref == 'refs/heads/master' permissions: contents: read @@ -178,6 +190,8 @@ jobs: - arch: armv6l - arch: aarch64 - arch: x86_64 + env: + CACHE_KEY: build-${{ matrix.arch }}-${{ needs.setup.outputs.week }} steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 @@ -237,8 +251,8 @@ jobs: push: true tags: ${{ steps.meta-busybox.outputs.tags }} labels: ${{ steps.meta-busybox.outputs.labels }} - cache-from: type=gha,scope=build-${{ matrix.arch }} - cache-to: type=gha,mode=max,scope=build-${{ matrix.arch }} + cache-from: type=gha,scope=${{ env.CACHE_KEY }} + cache-to: type=gha,mode=max,scope=${{ env.CACHE_KEY }} - name: Build and push rootfs to GHCR uses: >- @@ -253,5 +267,5 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha,scope=build-${{ matrix.arch }} - cache-to: type=gha,mode=max,scope=build-${{ matrix.arch }} + cache-from: type=gha,scope=${{ env.CACHE_KEY }} + cache-to: type=gha,mode=max,scope=${{ env.CACHE_KEY }}