Skip to content

Commit fe2df10

Browse files
authored
Create test-loop2.yml
1 parent a5b46f0 commit fe2df10

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/test-loop2.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: Test Loop
3+
on:
4+
push:
5+
branches: [development]
6+
7+
jobs:
8+
# Job 1: Collect data
9+
define-matrix:
10+
runs-on: ubuntu-latest
11+
12+
outputs:
13+
json-project: ${{ steps.project-step.outputs.json-project }}
14+
15+
steps:
16+
- name: Define Project String
17+
id: project-step
18+
run: |
19+
echo "json-project={\"count\":2,\"include\":[{\"project\":\"1\",\"config\":\"Debug\"},{\"project\":\"2\",\"config\":\"Release\"}]}" >> "$GITHUB_OUTPUT"
20+
21+
22+
# Job 2: Print the output of the "define-matrix" job
23+
print-output:
24+
runs-on: ubuntu-latest
25+
needs: define-matrix
26+
27+
steps:
28+
- name: Print project-json variable
29+
id: print-stuff
30+
run: |
31+
echo ${{ toJson(needs.define-matrix.outputs.project-string) }}
32+
echo ${{ toJson(needs.define-matrix.outputs.project-string) }} | jq -r '.include[].project'
33+
34+
# Job 3: Loop through array
35+
print-array-output:
36+
runs-on: ubuntu-latest
37+
needs: define-matrix
38+
39+
strategy:
40+
matrix:
41+
value: ${{ fromJson(needs.define-matrix.outputs.json-project) }}
42+
43+
steps:
44+
- name: Print project-json variable
45+
id: print-array-item
46+
run: |
47+
echo ${{ matrix.include[].project }}
48+
echo ${{ matrix }} | jq -r '.include[].project'

0 commit comments

Comments
 (0)