-
Notifications
You must be signed in to change notification settings - Fork 66
44 lines (38 loc) · 1.28 KB
/
Copy pathshared_matrix_prep.yml
File metadata and controls
44 lines (38 loc) · 1.28 KB
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
42
43
44
name: matrix_prep
on:
workflow_call:
inputs:
workflow_name:
description: 'Caller workflow name'
required: true
type: string
run_if:
description: 'True to get configuration matrix'
default: true
required: false
type: boolean
outputs:
matrix:
value: ${{ jobs.matrix_prep.outputs.matrix }}
permissions:
contents: read
jobs:
matrix_prep:
runs-on: ubuntu-22.04
if: ${{ inputs.run_if }}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Harden Runner
if: ${{ !github.event.repository.private }}
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- name: Check out repo
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- id: set-matrix
run: |
publicRepo=$(echo '${{ github.event.repository.private && 'privateRepo' || 'publicRepo' }}')
matrix=$(jq --arg publicRepo "$publicRepo" 'map(. | select((.runOn==$publicRepo) or (.runOn=="always")) )' matrix_includes_${{ inputs.workflow_name }}.json)
echo "matrix={\"include\":$(echo $matrix)}\"" >> $GITHUB_OUTPUT
working-directory: .github/