This subaction generates a multi-dimension matrix that can be used in a GitHub matrix
through the include property
so you can distribute your builds across multiple runners.

# docker-bake.hcl
group "validate" {
targets = ["lint", "doctoc"]
}
target "lint" {
target = "lint"
}
target "doctoc" {
target = "doctoc"
}
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
-
name: Checkout
uses: actions/checkout@v6
-
name: Generate matrix
id: generate
uses: docker/bake-action/subaction/matrix@v7
with:
target: validate
validate:
runs-on: ubuntu-latest
needs:
- prepare
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.prepare.outputs.matrix) }}
steps:
-
name: Validate
uses: docker/bake-action@v7
with:
targets: ${{ matrix.target }}
# docker-bake.hcl
target "lint" {
dockerfile = "./hack/dockerfiles/lint.Dockerfile"
output = ["type=cacheonly"]
platforms = [
"darwin/amd64",
"darwin/arm64",
"linux/amd64",
"linux/arm64",
"linux/s390x",
"linux/ppc64le",
"linux/riscv64",
"windows/amd64",
"windows/arm64"
]
}
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
-
name: Checkout
uses: actions/checkout@v6
-
name: Generate matrix
id: generate
uses: docker/bake-action/subaction/matrix@v7
with:
target: lint
fields: platforms
lint:
runs-on: ${{ startsWith(matrix.platforms, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
needs:
- prepare
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.prepare.outputs.matrix) }}
steps:
-
name: Lint
uses: docker/bake-action@v7
with:
targets: ${{ matrix.target }}
set: |
*.platform=${{ matrix.platforms }}
| Name |
Type |
Description |
workdir |
String |
Working directory to use (defaults to .) |
files |
List/CSV |
List of bake definition files |
target |
String |
The target to use within the bake file |
fields |
String |
List of extra fields to include in the matrix |
| Name |
Type |
Description |
matrix |
JSON |
Matrix configuration |