Skip to content

Commit 6a1015b

Browse files
committed
Download the model only once and re-use across all jobs
1 parent 7c76f51 commit 6a1015b

1 file changed

Lines changed: 38 additions & 11 deletions

File tree

.github/workflows/build-app-target-matrix.yml

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,31 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11+
prepare-model-artifact:
12+
name: Prepare Edge Impulse model artifact
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Build and deploy Edge Impulse model
19+
id: build-deploy
20+
uses: edgeimpulse/build-deploy@v2.0.0
21+
with:
22+
project_id: ${{ secrets['EDGE_IMPULSE_PROJECT_ID'] }}
23+
api_key: ${{ secrets['EDGE_IMPULSE_API_KEY'] }}
24+
engine: tflite
25+
deployment_type: zip
26+
27+
- name: Upload deployment artifact
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: edge-impulse-deployment
31+
path: ${{ steps.build-deploy.outputs.deployment_file_name }}
32+
if-no-files-found: error
33+
1134
build-matrix:
35+
needs: prepare-model-artifact
1236
name: ${{ matrix.app }} on ${{ matrix.target.name }}
1337
runs-on: ${{ matrix.target.runner }}
1438
strategy:
@@ -183,31 +207,34 @@ jobs:
183207
echo "Skipping ${{ matrix.app }} + ${{ matrix.target.name }}"
184208
echo "Reason: ${{ steps.validate.outputs.reason }}"
185209
186-
- name: Build and deploy Edge Impulse model
187-
if: matrix.app != 'APP_COLLECT'
188-
id: build-deploy
189-
uses: edgeimpulse/build-deploy@v2.0.0
210+
- name: Download deployment artifact
211+
if: matrix.app != 'APP_COLLECT' && steps.validate.outputs.supported == 'true'
212+
uses: actions/download-artifact@v4
190213
with:
191-
project_id: ${{ secrets['EDGE_IMPULSE_PROJECT_ID'] }}
192-
api_key: ${{ secrets['EDGE_IMPULSE_API_KEY'] }}
193-
engine: tflite
194-
deployment_type: zip-linux
214+
name: edge-impulse-deployment
215+
path: .
195216

196217
- name: Extract model and SDK
197-
if: matrix.app != 'APP_COLLECT'
218+
if: matrix.app != 'APP_COLLECT' && steps.validate.outputs.supported == 'true'
198219
shell: bash
199220
run: |
200221
set -euxo pipefail
201222
202223
rm -rf edge-impulse-sdk model-parameters tflite-model temp
203224
mkdir -p temp
204225
205-
unzip -q "${{ steps.build-deploy.outputs.deployment_file_name }}" -d temp
226+
deployment_file="$(find . -maxdepth 1 -type f -name '*.zip' | head -n 1)"
227+
if [[ -z "$deployment_file" ]]; then
228+
echo "No deployment zip file found after artifact download"
229+
exit 1
230+
fi
231+
232+
unzip -q "$deployment_file" -d temp
206233
mv temp/edge-impulse-sdk .
207234
mv temp/model-parameters .
208235
mv temp/tflite-model .
209236
210-
rm -rf "${{ steps.build-deploy.outputs.deployment_file_name }}" temp
237+
rm -rf "$deployment_file" temp
211238
212239
- name: Build
213240
if: steps.validate.outputs.supported == 'true'

0 commit comments

Comments
 (0)