-
Notifications
You must be signed in to change notification settings - Fork 1
41 lines (36 loc) · 1.27 KB
/
_utils_generate_matrix.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: Node JS Context Reusable Workflow
on:
workflow_call:
inputs:
package:
description: 'Package name'
type: string
default: 'all'
outputs:
matrix:
value: ${{ jobs.generate-matrix.outputs.matrix }}
env:
FORCE_COLOR: 1
jobs:
get-default-node-version:
uses: ./.github/workflows/_node_context.yml
generate-matrix:
needs: [get-default-node-version]
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout 🛎️
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Read Matrix File 📖
id: matrix
run: |
set -e
if [[ ${{ inputs.package }} = "all" ]]; then
echo "all"
else
jq '.package = ["${{ inputs.package }}"]' .github/workflows/matrix.json > /tmp/matrix.json && mv /tmp/matrix.json .github/workflows/matrix.json
fi
jq '.node_version = ["${{ needs.get-default-node-version.outputs.node_version }}"]' .github/workflows/matrix.json > /tmp/matrix.json && mv /tmp/matrix.json .github/workflows/matrix.json
MATRIX=$(echo $(cat .github/workflows/matrix.json | jq -RrS 'tostring'))
echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT