-
Notifications
You must be signed in to change notification settings - Fork 1
42 lines (39 loc) · 1.61 KB
/
matrix-from-previous-job-output-2.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
42
name: matrix-from-previous-job-output-2
on:
pull_request:
jobs:
setup:
outputs:
DEV_CHANGED: ${{ steps.changed-files-yaml.outputs.dev_any_changed }}
PROD_CHANGED: ${{ steps.changed-files-yaml.outputs.prod_any_changed }}
CHANGED_ENVS: ${{ steps.matrix.outputs.CHANGED_ENVS }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
with:
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
- name: get all changes for static/dev and static/prod
id: changed-files-yaml
uses: tj-actions/changed-files@v39
with:
files_yaml: |
dev:
- 'static/dev/**'
prod:
- 'static/prod/**'
- id: matrix
run: |
echo "dev: ${{ steps.changed-files-yaml.outputs.dev_any_changed }}" >> "$GITHUB_STEP_SUMMARY"
echo "prod: ${{ steps.changed-files-yaml.outputs.prod_any_changed }}" >> "$GITHUB_STEP_SUMMARY"
echo "CHANGED_ENVS=$(echo "[{\"env\": \"dev\", \"changed\": ${{ steps.changed-files-yaml.outputs.dev_any_changed }}}, {\"env\":\"prod\", \"changed\": ${{ steps.changed-files-yaml.outputs.prod_any_changed }} }]" | jq -c 'map(select( .changed ).env)')" >> "$GITHUB_OUTPUT"
execute:
if: needs.setup.outputs.CHANGED_ENVS != '[]'
strategy:
matrix:
env: ${{ fromJson(needs.setup.outputs.CHANGED_ENVS) }}
runs-on: ubuntu-latest
needs: [setup]
# if: ${{ matrix.env == 'dev' }} ❌ matrix value can be used only in steps
steps:
- run: |
echo "matrix: ${{ matrix.env }}"