@@ -125,21 +125,35 @@ runs:
125125 uses : actions/cache/restore@v4
126126 with :
127127 path : .firmware-action/
128- key : firmware-action-${{ hashFiles(inputs.config) }}-${{ github.sha }}
128+ key : firmware-action-${{ hashFiles(inputs.config) }}-${{ github.sha }}-${{ github.run_id }}
129129 restore-keys : |
130+ firmware-action-${{ hashFiles(inputs.config) }}-${{ github.sha }}-
130131 firmware-action-${{ hashFiles(inputs.config) }}-
131132 firmware-action-
132133
133134 - name : unpack_cached_files
134135 shell : bash
135136 run : |
137+ # Get output directories from config
136138 mapfile -t OUTPUT_DIRS < <(jq -r '[.. | objects | ."output_dir"? | select(. != null)][]' tests/example_config.json)
139+
140+ # For each output directory
137141 for DIR in "${OUTPUT_DIRS[@]}"; do
138- if [ -d ".firmware-action/${DIR}" ]; then
139- mv ".firmware-action/${DIR}" ./
142+ if [ -d ".firmware-action/artifacts/ ${DIR}" ]; then
143+ mv ".firmware-action/artifacts/ ${DIR}" ./
140144 fi
141145 done
142146
147+ # =====================
148+ # ARTIFACTS: Download
149+ # =====================
150+
151+ # - name: download_artifacts
152+ # uses: actions/download-artifact@v4
153+ # with:
154+ # name: artifacts-${{ inputs.target }}
155+ # path: .firmware-action2/
156+
143157 # =================================
144158 # RUN: firmware-action executable
145159 # =================================
@@ -168,14 +182,19 @@ runs:
168182 # CACHE: Create
169183 # ===============
170184
171- - name : pack_files_for_cache
185+ - name : copy_artifacts
172186 if : always()
173187 shell : bash
174188 run : |
175- mapfile -t OUTPUT_DIRS < <(jq -r '[.. | objects | ."output_dir"? | select(. != null)][]' tests/example_config.json)
189+ mkdir -p .firmware-action/artifacts/
190+
191+ # Get output directories from config
192+ mapfile -t OUTPUT_DIRS < <(jq -r '[.. | objects | ."output_dir"? | select(. != null)][]' "${{ inputs.config }}")
193+
194+ # For each output directory
176195 for DIR in "${OUTPUT_DIRS[@]}"; do
177196 if [ -d "${DIR}" ]; then
178- cp -r "${DIR}" .firmware-action/
197+ cp -r "${DIR}" .firmware-action/artifacts/
179198 fi
180199 done
181200
@@ -184,4 +203,26 @@ runs:
184203 uses : actions/cache/save@v4
185204 with :
186205 path : .firmware-action/
187- key : firmware-action-${{ hashFiles(inputs.config) }}-${{ github.sha }}
206+ key : firmware-action-${{ hashFiles(inputs.config) }}-${{ github.sha }}-${{ github.run_id }}
207+
208+ # ===================
209+ # ARTIFACTS: Upload
210+ # ===================
211+
212+ - name : get_output_dir
213+ if : always()
214+ shell : bash
215+ id : get_output_dir
216+ run : |
217+ # Extract output_dir for the specific target from config
218+ OUTPUT_DIR=$(jq -r --arg TARGET "${{ inputs.target }}" 'to_entries[] | select(.value | to_entries[].key == $TARGET) | .value[$TARGET].output_dir' "${{ inputs.config }}" | sed -E 's/\/$//g')
219+ echo "output_dir=${OUTPUT_DIR}" >> "${GITHUB_OUTPUT}"
220+
221+ - name : upload_artifacts
222+ if : always()
223+ uses : actions/upload-artifact@v4
224+ with :
225+ name : artifacts--${{ inputs.target }}--${{ steps.get_output_dir.outputs.output_dir }}
226+ path : .firmware-action/
227+ include-hidden-files : true
228+ overwrite : true
0 commit comments