From 4ffe517d524de0223dad36102e28f3f1579f9184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20=C5=81ukawski?= Date: Wed, 19 Jun 2024 17:01:36 +0200 Subject: [PATCH] Configure build matrix --- .github/workflows/ci.yml | 1 + .github/workflows/docker.yml | 45 +++++++++++++++++++++--------------- docker/Dockerfile | 2 +- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ef26a4c..37ca322d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,7 @@ on: push: paths-ignore: - 'doc/**' + - 'docker/**' - '**.md' pull_request: schedule: diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 93f97d17..615d209d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,30 +1,30 @@ name: Docker on: + push: + # paths: + # - 'docker/**' workflow_dispatch: - inputs: - ubuntu-tag: - description: 'The Ubuntu tag to use for the Docker image' - required: true - type: choice - options: - - '20.04' - - '22.04' - opencv-tag: - description: 'The OpenCV tag to use for the Docker image' - required: true - type: choice - options: - - '3.4' - - '4.x' - - '5.x' env: REGISTRY: ghcr.io + IMAGE_NAME: ${{github.repository}} jobs: docker: + name: build (Ubuntu ${{matrix.ubuntu}}, OpenCV ${{matrix.opencv}}) runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + id-token: write + + strategy: + matrix: + ubuntu: ['20.04', '22.04'] + opencv: ['4.x'] + steps: - name: Check out main project uses: actions/checkout@v4 @@ -36,12 +36,19 @@ jobs: username: ${{github.actor}} password: ${{secrets.GITHUB_TOKEN}} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{env.REGISTRY}}/${{env.IMAGE_NAME}} + - name: Build and push uses: docker/build-push-action@v6 with: push: true - tags: vision:ubuntu-${{inputs.ubuntu-tag}} context: docker + tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:ubuntu-${{matrix.ubuntu}}-opencv-${{matrix.opencv}} + labels: ${{steps.meta.outputs.labels}} build-args: | - OPENCV_TAG=${{inputs.opencv-tag}} - UBUNTU_TAG=${{inputs.ubuntu-tag}} + OPENCV_TAG=${{matrix.opencv}} + UBUNTU_TAG=${{matrix.ubuntu}} diff --git a/docker/Dockerfile b/docker/Dockerfile index 4a518e26..7204bdff 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,7 +14,7 @@ RUN apt-get update && \ -DBUILD_TESTS=OFF \ -DBUILD_PERF_TESTS=OFF \ -DOPENCV_ENABLE_NONFREE=ON && \ - cmake --build opencv-${OPENCV_TAG}/build -j && \ + cmake --build opencv-${OPENCV_TAG}/build && \ cmake --install opencv-${OPENCV_TAG}/build && \ rm -rf opencv.zip opencv_contrib.zip opencv-${OPENCV_TAG} opencv_contrib-${OPENCV_TAG} && \ apt-get clean