Skip to content

Commit

Permalink
ci(docker): Run the Docker build as part of PR checks
Browse files Browse the repository at this point in the history
To prevent that pull requests can break the Docker builds, change the
Docker build workflow to also be triggered by PRs and the merge queue.
In this case, do not push the images to the remote registry.

Fixes #1608.

Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
  • Loading branch information
mnonnenmacher committed Dec 13, 2024
1 parent 6d62ad1 commit bca220b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Docker Build

on:
merge_group:
types: [ checks_requested ]
pull_request:
branches:
- main
push:
branches:
- main
Expand Down Expand Up @@ -131,7 +136,8 @@ jobs:
with:
context: ${{ matrix.docker.context }}
file: ${{ matrix.docker.context }}/${{ matrix.docker.dockerfile }}
push: true
push: ${{ github.event_name != 'pull_request' && github.event_name != 'merge_group' }}
load: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
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
Expand Down Expand Up @@ -160,4 +166,6 @@ jobs:
-Djib.console=plain \
-Djib.container.labels="$(echo "${{ steps.meta.outputs.labels }}" | tr '\n' ',' | sed 's/,$//')" \
-Djib.to.tags="$(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ',' | sed 's/,$//')"
docker push ${{ env.REGISTRY }}/${{ github.repository_owner }}/ort-server-${{ matrix.docker.jibImage }} --all-tags
if [ "${{ github.event_name }}" != "pull_request" ] && [ "${{ github.event_name }}" != "merge_group" ]; then
docker push ${{ env.REGISTRY }}/${{ github.repository_owner }}/ort-server-${{ matrix.docker.jibImage }} --all-tags
fi

0 comments on commit bca220b

Please sign in to comment.