From d9b0260d607ec20a8478cdb8df2a9cc748d96452 Mon Sep 17 00:00:00 2001 From: "Gerber, Mike" Date: Fri, 10 Feb 2023 12:59:13 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20github:=20Test=20generating=20jo?= =?UTF-8?q?b=20outputs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/list-subimages | 36 ++++++++++++++++++++++++++++++++++++ .github/workflows/build.yml | 11 +++++++++++ 2 files changed, 47 insertions(+) create mode 100755 .github/list-subimages diff --git a/.github/list-subimages b/.github/list-subimages new file mode 100755 index 0000000..5d0e5ef --- /dev/null +++ b/.github/list-subimages @@ -0,0 +1,36 @@ +#!/usr/bin/python3 +import glob +import re +import sys +import argparse + +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")} +rest_subimages = all_subimages - core_subimages + + + +parser = argparse.ArgumentParser(description='List subimages.') +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') +args = parser.parse_args() + + +def list_(subimages): + subimages = sorted(subimages) + if args.csv: + print(",".join(subimages)) + else: + print("\n".join(subimages)) + + +if not args.core and not args.rest: + list_(core_subimages | rest_subimages) +if args.core: + list_(core_subimages) +if args.rest: + list_(rest_subimages) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fbd4c0f..a55343d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,6 +10,17 @@ on: - 'test/github-actions' jobs: + generate-matrix: + runs-on: ubuntu-latest + outputs: + core: ${{ steps.step1.outputs.core }} + rest: ${{ steps.step1.outputs.rest }} + steps: + - + id: step1 + run: | + echo "core=$(./.github/list-subimages --core --csv)" >>$GITHUB_OUTPUT + echo "rest=$(./.github/list-subimages --rest --csv)" >>$GITHUB_OUTPUT build-core: strategy: