diff --git a/.github/scripts/list-verticals.mts b/.github/scripts/list-verticals.mts index ac559982..9ecbfa29 100644 --- a/.github/scripts/list-verticals.mts +++ b/.github/scripts/list-verticals.mts @@ -1,11 +1,28 @@ import { verticals } from "./_meta.mts"; import * as actions from "@actions/core"; +import yargs from "yargs"; +import { hideBin } from "yargs/helpers"; -const type = process.argv[2]; +const argv = yargs(hideBin(process.argv)) + .option("type", { + type: "array", + required: true, + }) + .parse(); let output = verticals; -if (type) { - output = verticals.filter((v) => v.type === type); +if (argv.type) { + output = verticals.filter((v) => argv.type.includes(v.type)); } -actions.setOutput("verticals", JSON.stringify(output.map((v) => v.relPath))); +var matrix = { + path: output.map((v) => v.relPath), + include: output.map((v) => ({ + vertical: v.relPath, + name: v.name, + type: v.type, + })), +}; + +actions.setOutput("matrix", JSON.stringify(matrix)); +actions.setOutput("verticals", JSON.stringify(matrix.path)); diff --git a/.github/workflows/_find-verticals.yml b/.github/workflows/_find-verticals.yml index b9864a0b..cf269d02 100644 --- a/.github/workflows/_find-verticals.yml +++ b/.github/workflows/_find-verticals.yml @@ -3,6 +3,10 @@ name: "Template: Find verticals" on: workflow_call: outputs: + matrix: + value: ${{ github.event.inputs.matrix }} + description: JSON object containing a job matrix of verticals + verticals: value: ${{ jobs.list.outputs.verticals }} description: JSON list of folders in either @@ -20,6 +24,7 @@ jobs: outputs: verticals: ${{ steps.list.outputs.verticals }} + matrix: ${{ steps.list.outputs.matrix }} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/ci-apps.yml b/.github/workflows/ci-apps.yml index 7650ccc9..75de171e 100644 --- a/.github/workflows/ci-apps.yml +++ b/.github/workflows/ci-apps.yml @@ -23,8 +23,7 @@ jobs: runs-on: ubuntu-latest needs: find-verticals strategy: - matrix: - path: ${{ fromJson(needs.find-verticals.outputs.verticals) }} + matrix: ${{ fromJson(needs.find-verticals.outputs.matrix) }} steps: - uses: actions/checkout@v4