Skip to content

Commit

Permalink
fix(github): Do not cache-to Docker image builds from PRs
Browse files Browse the repository at this point in the history
External PRs do not have access to GitHub's container registry. While
pushing was already disabled for that case in d3ddb4d, the `cache-to`
part remained active. As that option cannot be conditionally disabled
alone, duplicate the respective steps with according conditionals.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Jun 12, 2024
1 parent 2c14d9a commit 8ebfe9a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,25 @@ jobs:
type=ref,event=tag
type=sha
- name: Build & Push 'ort' Docker Image
if: ${{ github.event_name != 'pull_request' }}
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
push: true
tags: ${{ steps.meta-ort.outputs.tags }}
labels: ${{ steps.meta-ort.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/ort:cache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/ort:cache,mode=max
build-args: ORT_VERSION=${{ env.ORT_VERSION }}
- name: Build 'ort' Docker Image
if: ${{ github.event_name == 'pull_request' }}
uses: docker/build-push-action@v5
with:
context: .
tags: ${{ steps.meta-ort.outputs.tags }}
labels: ${{ steps.meta-ort.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/ort:cache
build-args: ORT_VERSION=${{ env.ORT_VERSION }}
- name: Extract Metadata for 'ort-minimal' Docker Image
id: meta-ort-minimal
uses: docker/metadata-action@v5
Expand Down

0 comments on commit 8ebfe9a

Please sign in to comment.