diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63f56b8..7a3bdd3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -144,15 +144,34 @@ jobs: - name: Checkout uses: actions/checkout@v4 + # Detect runner flavor and pick cache mode + - name: Select Buildx cache backend + run: | + if [ "${ACT:-}" = "true" ]; then + echo "CACHE_TO=type=local,dest=/tmp/.buildx-cache,mode=max" >> $GITHUB_ENV + echo "CACHE_FROM=type=local,src=/tmp/.buildx-cache" >> $GITHUB_ENV + else + echo "CACHE_TO=type=gha,mode=max" >> $GITHUB_ENV + echo "CACHE_FROM=type=gha" >> $GITHUB_ENV + fi + + # (Only needed for local cache on act_runner) + - name: Prepare local Buildx cache dir + if: ${{ env.ACT == 'true' }} + run: mkdir -p /tmp/.buildx-cache + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + # optional: helps debugging cache issues + buildkitd-flags: --debug - name: Build image (no push) uses: docker/build-push-action@v5 with: context: . - push: false tags: keywarden:ci - # speeds up builds by caching layers on GH Actions - cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file + push: false # or true, if you want to push + load: false # set true if you need the image in the job afterward + cache-from: ${{ env.CACHE_FROM }} + cache-to: ${{ env.CACHE_TO }} \ No newline at end of file