From bfd788285a7c0bec25d530fdf413504dcea8928e Mon Sep 17 00:00:00 2001 From: Tim van Osch Date: Tue, 25 Jun 2024 14:37:40 +0200 Subject: [PATCH] ci: try spedup build --- .github/workflows/build-docker-images.yaml | 53 ++++++---------------- 1 file changed, 14 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build-docker-images.yaml b/.github/workflows/build-docker-images.yaml index 8ea82ecd..0aede907 100644 --- a/.github/workflows/build-docker-images.yaml +++ b/.github/workflows/build-docker-images.yaml @@ -16,7 +16,6 @@ jobs: test: name: Run Go Tests runs-on: ubuntu-latest - steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -26,47 +25,20 @@ jobs: with: go-version-file: ./go.mod - - name: Run Go Tests - run: go test ./... - - docker-cache: - name: Build cache image - needs: test - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Log in to GHCR - uses: docker/login-action@v3 + - name: Cache Go modules + uses: actions/cache@v3 with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile.cache - push: true - platforms: linux/amd64,linux/arm64 - tags: ${{ env.BUILDCACHE_TAG }} - cache-from: type=registry,ref=${{ env.BUILDCACHE_TAG }} - cache-to: type=registry,ref=${{ env.BUILDCACHE_TAG }},mode=max + - name: Run Go Tests + run: go test ./... docker: name: Build images - needs: docker-cache + needs: test runs-on: ubuntu-latest permissions: contents: read @@ -128,7 +100,7 @@ jobs: type=semver,pattern={{version}} - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: ${{ matrix.context }} file: ${{ matrix.dockerfile }} @@ -136,4 +108,7 @@ jobs: platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=${{ env.BUILDCACHE_TAG }} + cache-from: | + type=registry,ref=${{ env.REGISTRY }}/${{ matrix.image }}:buildcache + cache-to: | + type=registry,ref=${{ env.REGISTRY }}/${{ matrix.image }}:buildcache,mode=max