Skip to content

Commit

Permalink
[GitHub] Matrix strategy from JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonMarquis committed Jan 26, 2025
1 parent f6d43db commit 564ff41
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions docs/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,55 @@ jobs:
- run: java --version
```

### Matrix strategy from JSON

```yaml
jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- id: matrix
run: echo "matrix=$(jq --raw-output --compact-output . <<< "$CONFIG")" >> $GITHUB_OUTPUT
env:
CONFIG: >-
[
{
"id": "foo",
"value": "Hello, Foo!",
"array": [1, 2, 3]
},
{
"id": "bar",
"value": "Hello, Bar!",
"array": [3, 2, 1]
}
]
- run: jq . <<< "$MATRIX"
env:
MATRIX: ${{ steps.matrix.outputs.matrix }}
use-matrix:
name: Use matrix @${{ matrix.id }}
needs: setup-matrix
runs-on: ubuntu-latest
strategy:
matrix:
include: ${{ fromJSON(needs.setup-matrix.outputs.matrix) }}
steps:
- run: |
echo "ID=$ID"
echo "VALUE=$VALUE"
echo "ARRAYS=$ARRAYS"
env:
ID: ${{ matrix.id }}
VALUE: ${{ matrix.value }}
ARRAYS: ${{ join(matrix.array.*, ', ') }}
```

### Multline variables

!!! warning
Expand Down

0 comments on commit 564ff41

Please sign in to comment.