From ea7c9596fad177f5003c4b8354060be236e273bc Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Sat, 24 Sep 2022 18:55:50 +1000 Subject: [PATCH] Don't write to cache for pr builds --- .github/workflows/container.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index 16ffc52..f9d6972 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -27,23 +27,33 @@ jobs: - name: Setup Buildx uses: docker/setup-buildx-action@v2 - with: - buildkitd-flags: --debug - name: Login to GitHub Container Registry + if: ${{ github.event_name != 'pull_request' }} uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Build Images + if: ${{ github.event_name == 'pull_request' }} + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64, linux/386, linux/arm64, linux/arm/v6, linux/arm/v7 + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - name: Build and Push Images + if: ${{ github.event_name != 'pull_request' }} uses: docker/build-push-action@v3 with: context: . platforms: linux/amd64, linux/386, linux/arm64, linux/arm/v6, linux/arm/v7 cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max - push: ${{ github.event_name != 'pull_request' }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}