Enabling docker build (no push) on PR

This commit is contained in:
matlabbe
2026-06-20 12:53:46 -07:00
parent 507cb2c483
commit 1014e27b8a
+12 -3
View File
@@ -4,6 +4,9 @@ on:
push: push:
branches: branches:
- 'master' - 'master'
pull_request:
branches:
- '**'
jobs: jobs:
docker_deps: docker_deps:
@@ -15,7 +18,8 @@ jobs:
# $ sudo apt-get upgrade qemu-user-static # $ sudo apt-get upgrade qemu-user-static
# $ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes -c yes # $ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes -c yes
# More info: https://github.com/introlab/rtabmap/issues/1454 # More info: https://github.com/introlab/rtabmap/issues/1454
# if: false # Skipped on pull requests; built and pushed only on push to master.
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -85,6 +89,8 @@ jobs:
docker: docker:
needs: docker_deps needs: docker_deps
# Run even when docker_deps is skipped (it is, on pull requests).
if: ${{ !cancelled() && !failure() }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
@@ -190,6 +196,9 @@ jobs:
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- -
name: Login to DockerHub name: Login to DockerHub
# Only needed when pushing; skipped on pull requests (secrets are
# unavailable for fork PRs and we don't push there anyway).
if: github.event_name != 'pull_request'
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
@@ -199,8 +208,8 @@ jobs:
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: . context: .
push: true push: ${{ github.event_name != 'pull_request' }}
platforms: ${{ matrix.docker_platforms }} platforms: ${{ github.event_name == 'pull_request' && 'linux/amd64' || matrix.docker_platforms }}
file: ./docker/${{ matrix.docker_path }}/Dockerfile file: ./docker/${{ matrix.docker_path }}/Dockerfile
build-args: | build-args: |
${{ matrix.docker_args }} ${{ matrix.docker_args }}