Skip to content

Commit

Permalink
ci: matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alxandr committed Oct 9, 2024
1 parent 457cceb commit 58274ff
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
25 changes: 21 additions & 4 deletions .github/scripts/list-verticals.mts
Original file line number Diff line number Diff line change
@@ -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));
5 changes: 5 additions & 0 deletions .github/workflows/_find-verticals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <apps, pkgs, libs>
Expand All @@ -20,6 +24,7 @@ jobs:

outputs:
verticals: ${{ steps.list.outputs.verticals }}
matrix: ${{ steps.list.outputs.matrix }}

steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ci-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 58274ff

Please sign in to comment.