🚧 github: TUse dynamic build matrix

test/github-actions
Gerber, Mike 2 years ago
parent 958db4d0e9
commit 31fe37c36c

@ -3,6 +3,8 @@ import glob
import re
import sys
import argparse
import json
all_subimages = {re.sub(r"^Dockerfile-", "", dockerfile) for dockerfile in glob.glob("Dockerfile-*")}
core_subimages = {si for si in all_subimages if si.startswith("core")}
@ -15,15 +17,15 @@ parser.add_argument('--core', action='store_true',
default=False, help='List core subimages')
parser.add_argument('--rest', action='store_true',
default=False, help='List rest subimages')
parser.add_argument('--csv', action='store_true',
default=False, help='Return list as CSV')
parser.add_argument('--json', action='store_true',
default=False, help='Return list as JSON')
args = parser.parse_args()
def list_(subimages):
subimages = sorted(subimages)
if args.csv:
print(",".join(subimages))
if args.json:
print(json.dumps(subimages))
else:
print("\n".join(subimages))

@ -10,7 +10,7 @@ on:
- 'test/github-actions'
jobs:
generate-matrix:
matrix:
runs-on: ubuntu-latest
outputs:
core: ${{ steps.step1.outputs.core }}
@ -23,13 +23,14 @@ jobs:
name: Generate outputs
id: step1
run: |
echo "core=$(./.github/list-subimages --core --csv)" >>$GITHUB_OUTPUT
echo "rest=$(./.github/list-subimages --rest --csv)" >>$GITHUB_OUTPUT
echo "core=$(./.github/list-subimages --core --json)" >>$GITHUB_OUTPUT
echo "rest=$(./.github/list-subimages --rest --json)" >>$GITHUB_OUTPUT
build-core:
needs: matrix
strategy:
matrix:
subimage: ["core"]
subimage: ${{ fromJson(needs.matrix.outputs.core) }}
uses: ./.github/workflows/build-subimage.yml
with:
subimage: ${{ matrix.subimage }}

Loading…
Cancel
Save