Skip to content

Modern Docker Management, Designed for Everyone

ci/cd: consolidate build next workflows using matrix

Kyle Mendell5e4229b39bce
diff --git a/.github/workflows/build-agent-next.yml b/.github/workflows/build-agent-next.yml
deleted file mode 100644
index 6fdd9a6c7..000000000
--- a/.github/workflows/build-agent-next.yml
+++ /dev/null
@@ -1,73 +0,0 @@
-name: Build Next Image (Agent)
-
-on:
- push:
- branches: [main]
- paths:
- - "backend/**"
- - "frontend/**"
- - "package.json"
- - "pnpm-lock.yaml"
- - "frontend/package.json"
- workflow_dispatch:
-
-concurrency:
- group: build-agent-next
- cancel-in-progress: true
-
-jobs:
- build-agent:
- runs-on: release-latest
- permissions:
- contents: read
- packages: write
- id-token: write
- attestations: write
-
- steps:
- - name: Checkout code
- uses: actions/checkout@v5
-
- - name: Set up QEMU
- uses: docker/setup-qemu-action@v3
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
-
- - name: Setup Go
- uses: actions/setup-go@v6
- with:
- go-version-file: backend/go.mod
-
- - name: Set DOCKER_IMAGE_NAME
- run: |
- REPO_OWNER=${{ github.repository_owner }}
- DOCKER_IMAGE_NAME="ghcr.io/${REPO_OWNER,,}/arcane-headless"
- echo "DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME}" >>${GITHUB_ENV}
-
- - name: Login to GHCR
- uses: docker/login-action@v3
- with:
- registry: ghcr.io
- username: ${{ github.repository_owner }}
- password: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Build agent binaries
- run: bash scripts/github/build-binaries.sh --docker --agent
-
- - name: Build and push agent image
- id: build-push-image
- uses: docker/build-push-action@v6
- with:
- context: .
- file: docker/Dockerfile-agent-static
- platforms: linux/amd64,linux/arm64
- push: true
- tags: ${{ env.DOCKER_IMAGE_NAME }}:next
-
- - name: Attest build provenance
- uses: actions/attest-build-provenance@v3
- with:
- subject-name: "${{ env.DOCKER_IMAGE_NAME }}"
- subject-digest: ${{ steps.build-push-image.outputs.digest }}
- push-to-registry: true
diff --git a/.github/workflows/build-next.yml b/.github/workflows/build-next-images.yml
similarity index 72%
rename from .github/workflows/build-next.yml
rename to .github/workflows/build-next-images.yml
index 3b50fac9a..e846cf7cf 100644
--- a/.github/workflows/build-next.yml
+++ b/.github/workflows/build-next-images.yml
@@ -1,19 +1,13 @@
-name: Build Next Image (Manager)
+name: Build Next Images
on:
push:
branches:
- main
- paths:
- - "backend/**"
- - "frontend/**"
- - "package.json"
- - "pnpm-lock.yaml"
- - "frontend/package.json"
workflow_dispatch:
concurrency:
- group: build-next-image
+ group: build-next-images
cancel-in-progress: true
jobs:
@@ -24,6 +18,19 @@ jobs:
packages: write
id-token: write
attestations: write
+ strategy:
+ fail-fast: false
+ matrix:
+ image:
+ - name: manager
+ dockerfile: docker/Dockerfile-static
+ image-name: arcane
+ build-args: ""
+ - name: agent
+ dockerfile: docker/Dockerfile-agent-static
+ image-name: arcane-headless
+ build-args: --agent
+ name: Build Next Image (${{ matrix.image.name }})
steps:
- name: Checkout code
uses: actions/checkout@v5
@@ -50,7 +57,7 @@ jobs:
- name: Set DOCKER_IMAGE_NAME
run: |
REPO_OWNER=${{ github.repository_owner }}
- DOCKER_IMAGE_NAME="ghcr.io/${REPO_OWNER,,}/arcane"
+ DOCKER_IMAGE_NAME="ghcr.io/${REPO_OWNER,,}/${{ matrix.image.image-name }}"
echo "DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME}" >>${GITHUB_ENV}
- name: Login to GitHub Container Registry
@@ -61,13 +68,15 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install frontend dependencies
+ if: matrix.image.name == 'manager'
run: pnpm --filter arcane-frontend install --frozen-lockfile
- name: Build frontend
+ if: matrix.image.name == 'manager'
run: pnpm --filter arcane-frontend build
- name: Build binaries
- run: bash scripts/github/build-binaries.sh --docker
+ run: bash scripts/github/build-binaries.sh --docker ${{ matrix.image.build-args }}
- name: Build and push container image
id: build-push-image
@@ -77,7 +86,8 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKER_IMAGE_NAME }}:next
- file: docker/Dockerfile-static
+ file: ${{ matrix.image.dockerfile }}
+
- name: Container image attestation
uses: actions/attest-build-provenance@v3
with: