1212 - cron : " 42 8 1 * *"
1313
1414jobs :
15+ generate-matrix :
16+ name : Generate Matrix
17+ runs-on : ubuntu-latest
18+ outputs :
19+ analyzers_matrix : ${{ steps.set-matrix.outputs.analyzers_matrix }}
20+ responders_matrix : ${{ steps.set-matrix.outputs.responders_matrix }}
21+ steps :
22+ - name : Checkout repository
23+ uses : actions/checkout@v4
24+ with :
25+ fetch-depth : 0
26+
27+ - name : List analyzer and responder directories and build matrices
28+ id : set-matrix
29+ run : |
30+ echo "Listing analyzer directories in 'analyzers/'..."
31+ analyzer_dirs=$(find analyzers -mindepth 1 -maxdepth 1 -type d -printf '%f\n')
32+ echo "Found analyzer directories:"
33+ echo "$analyzer_dirs"
34+
35+ echo "Listing responder directories in 'responders/'..."
36+ responder_dirs=$(find responders -mindepth 1 -maxdepth 1 -type d -printf '%f\n')
37+ echo "Found responder directories:"
38+ echo "$responder_dirs"
39+
40+ # Build JSON for analyzers (each object has a directory name)
41+ analyzer_json=$(echo "$analyzer_dirs" | jq -R -s -c 'split("\n")[:-1] | map({directory: .})')
42+ # Build JSON for responders
43+ responder_json=$(echo "$responder_dirs" | jq -R -s -c 'split("\n")[:-1] | map({directory: .})')
44+
45+ # Add a component key to each and wrap them with "include"
46+ analyzers_matrix=$(echo "$analyzer_json" | jq -c '{include: map(. + {component: "analyzers"})}')
47+ responders_matrix=$(echo "$responder_json" | jq -c '{include: map(. + {component: "responders"})}')
48+
49+ echo "Generated analyzers matrix: $analyzers_matrix"
50+ echo "Generated responders matrix: $responders_matrix"
51+
52+ {
53+ echo "analyzers_matrix<<EOF"
54+ echo "$analyzers_matrix"
55+ echo "EOF"
56+ } >> "$GITHUB_OUTPUT"
57+
58+ {
59+ echo "responders_matrix<<EOF"
60+ echo "$responders_matrix"
61+ echo "EOF"
62+ } >> "$GITHUB_OUTPUT"
63+
1564 build_analyzers :
1665 name : Build Analyzers
17- runs-on : [ ubuntu-latest ]
66+ needs : generate-matrix
67+ runs-on : ubuntu-latest
68+ strategy :
69+ matrix : ${{ fromJson(needs.generate-matrix.outputs.analyzers_matrix) }}
1870 steps :
19- - name : Checkout
71+ - name : Checkout repository
2072 uses : actions/checkout@v4
2173 with :
2274 fetch-depth : 0
23- - name : Build analyzers
75+
76+ - name : Pre-pull builder image (if not already cached)
77+ run : docker pull thehiveproject/cortex-neurons-builder:latest
78+
79+ - name : Build analyzer ${{ matrix.directory }}
2480 uses : docker://thehiveproject/cortex-neurons-builder:latest
2581 with :
2682 driver-opts : image=moby/buildkit:v0.19.0
2783 args : |
28- --namespace cortexneurons --path analyzers --registry_dockerhub ${{ secrets.REGISTRY_DOCKERHUB }} ${{ (startsWith(github.ref, 'refs/tags') || github.event_name == 'schedule') && '--stable' || '' }}
84+ --namespace cortexneurons --path analyzers -w ${{ matrix.directory }} - -registry_dockerhub ${{ secrets.REGISTRY_DOCKERHUB }} ${{ (startsWith(github.ref, 'refs/tags') || github.event_name == 'schedule') && '--stable' || '' }}
2985
3086 build_responders :
3187 name : Build Responders
32- runs-on : [ ubuntu-latest ]
88+ needs : generate-matrix
89+ runs-on : ubuntu-latest
90+ strategy :
91+ matrix : ${{ fromJson(needs.generate-matrix.outputs.responders_matrix) }}
3392 steps :
34- - name : Checkout
93+ - name : Checkout repository
3594 uses : actions/checkout@v4
3695 with :
3796 fetch-depth : 0
38- - name : Build responders
97+
98+ - name : Pre-pull builder image (if not already cached)
99+ run : docker pull thehiveproject/cortex-neurons-builder:latest
100+
101+ - name : Build responder ${{ matrix.directory }}
39102 uses : docker://thehiveproject/cortex-neurons-builder:latest
40103 with :
41104 driver-opts : image=moby/buildkit:v0.19.0
42105 args : |
43- --namespace cortexneurons --path responders --registry_dockerhub ${{ secrets.REGISTRY_DOCKERHUB }} ${{ (startsWith(github.ref, 'refs/tags') || github.event_name == 'schedule') && '--stable' || '' }}
106+ --namespace cortexneurons --path responders -w ${{ matrix.directory }} - -registry_dockerhub ${{ secrets.REGISTRY_DOCKERHUB }} ${{ (startsWith(github.ref, 'refs/tags') || github.event_name == 'schedule') && '--stable' || '' }}
44107
45108 build_catalog :
46109 name : Build Catalog
47- runs-on : [ ubuntu-latest ]
110+ runs-on : ubuntu-latest
48111 needs : [ build_analyzers, build_responders ]
49112 if : always()
50113 steps :
51- - name : Checkout
114+ - name : Checkout repository
52115 uses : actions/checkout@v4
53116 - name : Build catalog
54117 uses : docker://thehiveproject/neurons-build-catalogs
76139
77140 build_docs :
78141 name : Build documentation
79- runs-on : [ ubuntu-latest ]
80- needs : [build_analyzers, build_responders ]
142+ runs-on : ubuntu-latest
143+ needs : [ build_analyzers, build_responders ]
81144 if : startsWith(github.ref, 'refs/tags/') && always()
82145 steps :
83146 - uses : actions/checkout@v4
@@ -92,21 +155,24 @@ jobs:
92155 architecture : x64
93156 - name : Install requirements
94157 run : python3 -m pip install -r utils/test_doc/requirements.txt
95- - name : setup git user
96- run : git config user.name 'github-actions[bot]' && git config user.email 'github-actions[bot]@users.noreply.github.com'
97- - name : Deploy
158+ - name : Set up git user
159+ run : |
160+ git config user.name 'github-actions[bot]'
161+ git config user.email 'github-actions[bot]@users.noreply.github.com'
162+ - name : Deploy documentation
98163 run : python3 -m mkdocs gh-deploy --remote-branch gh-pages --force
99164
100165 notify :
101- needs : [build_analyzers, build_responders, build_catalog, build_docs ]
102- runs-on : [ ubuntu-latest ]
103- if : always()
166+ name : Notify
167+ needs : [ build_analyzers, build_responders, build_catalog, build_docs ]
168+ runs-on : ubuntu-latest
169+ if : false # Temporarily disable notifications
104170 steps :
105171 - name : Slack notification
106172 uses : Gamesight/slack-workflow-status@master
107173 with :
108- repo_token : ${{secrets.GITHUB_TOKEN}}
109- slack_webhook_url : ${{secrets.SLACK_WEBHOOK_URL}}
174+ repo_token : ${{ secrets.GITHUB_TOKEN }}
175+ slack_webhook_url : ${{ secrets.SLACK_WEBHOOK_URL }}
110176 channel : " #ci-cortex"
111177 name : Cortex Analyzers build
112178 include_commit_message : true
0 commit comments