diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 4c678ca4..11585597 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -26,9 +26,25 @@ jobs: with: auto-commit: "true" + build-cache-check: + runs-on: ubuntu-latest + outputs: + cache-hit: ${{ steps.cache.outputs.cache-hit }} + steps: + - name: Checkout + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - uses: actions/cache@v4 + id: cache + with: + path: /tmp/alfresco-docker-images.tar + key: docker-${{ runner.os }}-${{ hashFiles('docker-bake.hcl','**/Dockerfile','**/artifacts.json','**/entrypoint.sh') }} + lookup-only: true + build-test: runs-on: ubuntu-latest - needs: pre-commit + needs: build-cache-check + if: '! needs.build-cache-check.outputs.cache-hit' steps: - name: Checkout uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 @@ -70,17 +86,19 @@ jobs: run: | docker save -o /tmp/alfresco-docker-images.tar $(docker images --format "{{.Repository}}:{{.Tag}}" | grep alfresco) - - name: Upload images as artifact - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 + - name: Save docker archive + id: cache-save + uses: actions/cache/save@v4 with: - name: docker-images path: /tmp/alfresco-docker-images.tar - retention-days: 1 - compression-level: 0 + key: docker-${{ runner.os }}-${{ hashFiles('docker-bake.hcl','**/Dockerfile','**/artifacts.json','**/entrypoint.sh') }} compose-test: name: compose-test ${{ matrix.docker-compose-file }} - needs: build-test + needs: + - build-cache-check + - build-test + if: always() && (needs.build-test.result == 'success' || needs.build-test.result == 'skipped') runs-on: ubuntu-latest strategy: matrix: @@ -88,12 +106,13 @@ jobs: steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 - - - name: Download artifacts - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + + - name: Restore cache + uses: actions/cache/restore@v4 with: - path: /tmp - name: docker-images + path: /tmp/alfresco-docker-images.tar + key: docker-${{ runner.os }}-${{ hashFiles('docker-bake.hcl','**/Dockerfile','**/artifacts.json','**/entrypoint.sh') }} + fail-on-cache-miss: true - name: Load Docker images run: |