From ee3d7ef127d2435b94cffff5609c53d203adaf91 Mon Sep 17 00:00:00 2001 From: Zespre Schmidt Date: Sun, 28 Jul 2024 15:11:29 +0800 Subject: [PATCH] ci: use GHA matrix to build two images Signed-off-by: Zespre Schmidt --- .github/workflows/main.yml | 33 +++++++++-------------------- .github/workflows/pull-request.yaml | 29 +++++++++++-------------- .github/workflows/tag.yml | 33 +++++++++-------------------- 3 files changed, 32 insertions(+), 63 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1e420ee..ecb2fe1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,13 +8,16 @@ on: jobs: build-main: runs-on: ubuntu-latest + strategy: + matrix: + include: + - dockerfile: ./Dockerfile + image: starbops/kubebmc-controller + - dockerfile: ./Dockerfile.kbmc + image: starbops/kbmc steps: - name: Check out repository code uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -28,30 +31,14 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: | - starbops/kubebmc-controller - starbops/kbmc - - name: Test - run: make test - - name: Build - run: make build - - name: Docker build and push (controller) - uses: docker/build-push-action@v6 - with: - provenance: false - context: . - platforms: linux/amd64,linux/arm64 - file: ./Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - name: Docker build and push (kbmc) + images: ${{ matrix.image }} + - name: Docker build and push uses: docker/build-push-action@v6 with: provenance: false context: . platforms: linux/amd64,linux/arm64 - file: ./Dockerfile.kbmc + file: ${{ matrix.dockerfile }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index cdbbef0..c0e8ab9 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -9,6 +9,13 @@ on: jobs: build-pr: runs-on: ubuntu-latest + strategy: + matrix: + include: + - dockerfile: ./Dockerfile + image: starbops/kubebmc-controller + - dockerfile: ./Dockerfile.kbmc + image: starbops/kbmc steps: - name: Check out repository code uses: actions/checkout@v4 @@ -24,30 +31,18 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: | - starbops/kubebmc-controller - starbops/kbmc - - name: Test + images: ${{ matrix.image }} + - name: Run tests run: make test - - name: Build + - name: Build binaries run: make build - - name: Docker build (controller) + - name: Docker build uses: docker/build-push-action@v6 with: provenance: false context: . platforms: linux/amd64,linux/arm64 - file: ./Dockerfile - push: false - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - name: Docker build (kbmc) - uses: docker/build-push-action@v6 - with: - provenance: false - context: . - platforms: linux/amd64,linux/arm64 - file: ./Dockerfile.kbmc + file: ${{ matrix.dockerfile }} push: false tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 71170e0..2229c77 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -8,13 +8,16 @@ on: jobs: build-tag: runs-on: ubuntu-latest + strategy: + matrix: + include: + - dockerfile: ./Dockerfile + image: starbops/kubebmc-controller + - dockerfile: ./Dockerfile.kbmc + image: starbops/kbmc steps: - name: Check out repository code uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.22' - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -28,30 +31,14 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: | - starbops/kubebmc-controller - starbops/kbmc - - name: Test - run: make test - - name: Build - run: make build - - name: Docker build and push (controller) - uses: docker/build-push-action@v6 - with: - provenance: false - context: . - platforms: linux/amd64,linux/arm64 - file: ./Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - name: Docker build and push (kbmc) + images: ${{ matrix.image }} + - name: Docker build and push uses: docker/build-push-action@v6 with: provenance: false context: . platforms: linux/amd64,linux/arm64 - file: ./Dockerfile.kbmc + file: ${{ matrix.dockerfile }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}