Skip to content

Commit

Permalink
ci(docker): Do not write to the registry cache in pull requests checks
Browse files Browse the repository at this point in the history
Writing to the cache causes a permission problem when pull requests are
created from a fork. Also, the cache should only be written to from main
branch builds anyway.

Signed-off-by: Martin Nonnenmacher <[email protected]>
  • Loading branch information
mnonnenmacher committed Dec 16, 2024
1 parent ca15038 commit 8511119
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ jobs:
type=sha
type=raw,value=latest,enable={{ is_default_branch }}
- name: Set cache-to
id: set-cache-to
run: echo "cache_to=$([[ ${{ !env.IS_PR }} == 'true' ]] && echo 'type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/ort-server-${{ matrix.docker.image }}:cache,mode=max' || echo '')" >> $GITHUB_ENV

- name: Build ${{ matrix.docker.image }} Image
if: ${{ matrix.docker.dockerfile != '' }}
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6
Expand All @@ -142,7 +146,7 @@ jobs:
tags: ${{ steps.meta-base.outputs.tags }}
labels: ${{ steps.meta-base.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/ort-server-${{ matrix.docker.image }}:cache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/ort-server-${{ matrix.docker.image }}:cache,mode=max
cache-to: ${{ steps.set-cache-to.output.cache-to }}

- name: Extract Docker Metadata for ${{ matrix.docker.jibImage }} Image
if: ${{ matrix.docker.task != '' }}
Expand Down

0 comments on commit 8511119

Please sign in to comment.