-
Notifications
You must be signed in to change notification settings - Fork 56
66 lines (63 loc) · 2.61 KB
/
detect-changes-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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Detect Changes
on:
workflow_call:
outputs:
matrix:
value: ${{ jobs.detect-changes.outputs.matrix }}
description: "Matrix of changed integrations / Ocean Core per git commit changes"
integrations:
description: "Matrix of changed integrations per git commit changes"
value: ${{ jobs.detect-changes.outputs.integrations }}
core:
value: ${{ jobs.detect-changes.outputs.core }}
description: "Determine if any core changes per git commit changes"
infra:
value: ${{ jobs.detect-changes.outputs.infra }}
description: "Determine if any changes to docker infra"
jobs:
detect-changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-all-matrix.outputs.matrix }}
integrations: ${{ steps.set-all-matrix.outputs.integrations }}
core: ${{ steps.set-all-matrix.outputs.core }}
infra: ${{ steps.set-all-matrix.outputs.infra}}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Get list of changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
dir_names: true
json: true
dir_names_max_depth: 2
escape_json: false
files_yaml: |
core:
- '!integrations/**'
- '!scripts/*'
- '!scripts/*'
- '!./*.md'
integrations:
- 'integrations/**'
- '!integrations/**/*.md'
- '!integrations/_infra/*'
infra:
- 'integrations/_infra/*'
- name: Set integrations and all matrix
id: set-all-matrix
run: |
INTEGRATIONS=$(node -e 'integrations=${{ steps.changed-files.outputs.integrations_all_changed_files }};console.log(JSON.stringify(integrations.map(integration => integration.split("/")[1])))')
HAS_CORE=${{ steps.changed-files.outputs.core_all_changed_files != '[]' }}
echo "Core changes : ${HAS_CORE}"
MATRIX=$(node -e "integrations=${INTEGRATIONS}; hasCore=${HAS_CORE}; console.log(JSON.stringify(hasCore ? integrations.concat(['.']) : integrations))")
HAS_INFRA=${{ steps.changed-files.outputs.infra_all_changed_files != '[]' }}
echo "Infra changes : ${HAS_INFRA}"
echo "Integration changes : ${INTEGRATIONS}"
echo "All changes : ${MATRIX}"
echo "core=${HAS_CORE}" >> $GITHUB_OUTPUT
echo "integrations=${INTEGRATIONS}" >> $GITHUB_OUTPUT
echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT
echo "infra=${HAS_INFRA}" >> $GITHUB_OUTPUT