Skip to content

Commit 3c3fbf8

Browse files
committed
test set-matrix job
1 parent c7a125d commit 3c3fbf8

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

.github/workflows/test_changed_files.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ on:
66
types: [synchronize, opened, reopened, ready_for_review]
77

88
jobs:
9-
test:
10-
name: Test changed-files
11-
runs-on: "ubuntu-latest"
9+
set-matrix-job:
10+
name: Set jobs by changed Dockerfile
11+
runs-on: ubuntu-latest
12+
outputs:
13+
matrix: ${{ steps.set-matrix.outputs.matrix }}
1214
steps:
1315
- name: Checkount
1416
uses: actions/checkout@v3
@@ -17,8 +19,22 @@ jobs:
1719
id: changed-files
1820
uses: tj-actions/changed-files@v23
1921

20-
- name: List all changed files
22+
- name: Set jobs' matrix
23+
id: set-matrix
2124
run: |
22-
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
23-
echo "$file was changed"
24-
done
25+
filtered=''
26+
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
27+
if [[ "$file" == *"Dockerfile"* ]]; then
28+
parsed=${file%*/Dockerfile*}
29+
filtered="${filtered} ${parsed}"
30+
fi
31+
done
32+
echo "::set-output name=matrix::${filtered}"
33+
test:
34+
needs: set-matrix-job
35+
runs-on: "ubuntu-latest"
36+
strategy:
37+
matrix:
38+
sorter: ${{ needs.set-matrix-job.outputs.matrix }}
39+
steps:
40+
- run: echo ${{ matrix.sorter }}

0 commit comments

Comments
 (0)