Skip to content

Commit 2cda885

Browse files
maennchensschuberth
authored andcommitted
feat: add action outputs for exit codes & result files
Signed-off-by: Jonatan Männchen <[email protected]>
1 parent 3832002 commit 2cda885

File tree

1 file changed

+58
-8
lines changed

1 file changed

+58
-8
lines changed

action.yml

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,44 @@ inputs:
207207
By default, the Git short SHA is used.
208208
required: false
209209

210+
outputs:
211+
evaluator-exit-code:
212+
description: The exit code of the evaluator CLI command.
213+
value: "${{ steps.ort-evaluator.outputs.exit-code }}"
214+
advisor-exit-code:
215+
description: The exit code of the advisor CLI command.
216+
value: "${{ steps.ort-advisor.outputs.exit-code }}"
217+
results-path:
218+
description: Path to the result directory.
219+
value: "${{ steps.ort-init.outputs.results-path }}"
220+
results-advisor-path:
221+
description: Path to the advisor result file.
222+
value: "${{ steps.ort-init.outputs.results-advisor-path }}"
223+
results-evaluator-path:
224+
description: Path to the evaluator result file.
225+
value: "${{ steps.ort-init.outputs.results-evaluator-path }}"
226+
results-scanner-path:
227+
description: Path to the scanner result file.
228+
value: "${{ steps.ort-init.outputs.results-scanner-path }}"
229+
results-html-report-path:
230+
description: Path to the HTML report file.
231+
value: "${{ steps.ort-init.outputs.results-html-report-path }}"
232+
results-sbom-cyclonedx-xml-path:
233+
description: Path to the CycloneDX XML SBoM file.
234+
value: "${{ steps.ort-init.outputs.results-sbom-cyclonedx-xml-path }}"
235+
results-sbom-cyclonedx-json-path:
236+
description: Path to the CycloneDX JSON SBoM file.
237+
value: "${{ steps.ort-init.outputs.results-sbom-cyclonedx-json-path }}"
238+
results-sbom-spdx-json-path:
239+
description: Path to the SPDX JSON SBoM file.
240+
value: "${{ steps.ort-init.outputs.results-sbom-spdx-json-path }}"
241+
results-sbom-spdx-yml-path:
242+
description: Path to the SPDX YML SBoM file.
243+
value: "${{ steps.ort-init.outputs.results-sbom-spdx-yml-path }}"
244+
results-web-app-path:
245+
description: Path to the Web App Report file.
246+
value: "${{ steps.ort-init.outputs.results-web-app-path }}"
247+
210248
runs:
211249
using: 'composite'
212250
steps:
@@ -247,17 +285,29 @@ runs:
247285
mkdir -p $HOME/go/; chmod -R aug+w ${HOME}/go/ || :
248286
export ORT_CONFIG_PATH=${ORT_CONFIG_PATH:-"$HOME/$ORT_HOME_PATH/config"}
249287
export ORT_RESULTS_PATH="$HOME/$ORT_HOME_PATH/ort-results"
288+
echo "results-path=${ORT_RESULTS_PATH}" >> "$GITHUB_OUTPUT"
250289
export ORT_RESULTS_ADVISOR_PATH="${ORT_RESULTS_PATH}/advisor-result.json"
290+
echo "results-advisor-path=${ORT_RESULTS_ADVISOR_PATH}" >> "$GITHUB_OUTPUT"
251291
export ORT_RESULTS_ANALYZER_PATH="${ORT_RESULTS_PATH}/analyzer-result.json"
292+
echo "results-analyzer-path=${ORT_RESULTS_ANALYZER_PATH}" >> "$GITHUB_OUTPUT"
252293
export ORT_RESULTS_CURRENT_PATH="${ORT_RESULTS_PATH}/current-result.json"
253294
export ORT_RESULTS_EVALUATED_MODEL_PATH="${ORT_RESULTS_PATH}/evaluated-model.json"
254295
export ORT_RESULTS_EVALUATOR_PATH="${ORT_RESULTS_PATH}/evaluation-result.json"
255-
export ORT_RESULTS_HTML_REPORT_PATH="${ORT_RESULTS_PATH}/ort-results/scan-report.html"
296+
echo "results-evaluator-path=${ORT_RESULTS_EVALUATOR_PATH}" >> "$GITHUB_OUTPUT"
297+
export ORT_RESULTS_HTML_REPORT_PATH="${ORT_RESULTS_HTML_REPORT_PATH}/ort-results/scan-report.html"
298+
echo "results-html-report-path=${ORT_RESULTS_SCANNER_PATH}" >> "$GITHUB_OUTPUT"
256299
export ORT_RESULTS_SCANNER_PATH="${ORT_RESULTS_PATH}/scan-result.json"
300+
echo "results-scanner-path=${ORT_RESULTS_SCANNER_PATH}" >> "$GITHUB_OUTPUT"
257301
export ORT_RESULTS_SBOM_CYCLONE_XML_PATH="${ORT_RESULTS_PATH}/bom.cyclonedx.xml"
302+
echo "results-sbom-cyclonedx-xml-path=${ORT_RESULTS_SBOM_CYCLONE_XML_PATH}" >> "$GITHUB_OUTPUT"
303+
export ORT_RESULTS_SBOM_CYCLONE_JSON_PATH="${ORT_RESULTS_PATH}/bom.cyclonedx.json"
304+
echo "results-sbom-cyclonedx-json-path=${ORT_RESULTS_SBOM_CYCLONE_JSON_PATH}" >> "$GITHUB_OUTPUT"
258305
export ORT_RESULTS_SBOM_SPDX_JSON_PATH="${ORT_RESULTS_PATH}/bom.spdx.json"
306+
echo "results-sbom-spdx-json-path=${ORT_RESULTS_SBOM_SPDX_JSON_PATH}" >> "$GITHUB_OUTPUT"
259307
export ORT_RESULTS_SBOM_SPDX_YML_PATH="${ORT_RESULTS_PATH}/bom.spdx.yml"
308+
echo "results-sbom-spdx-yml-path=${ORT_RESULTS_SBOM_SPDX_YML_PATH}" >> "$GITHUB_OUTPUT"
260309
export ORT_RESULTS_WEB_APP_PATH="${ORT_RESULTS_PATH}/scan-report-web-app.html"
310+
echo "results-web-app-path=${ORT_RESULTS_WEB_APP_PATH}" >> "$GITHUB_OUTPUT"
261311
SW_NAME=${SW_NAME:-"unknown"}
262312
SW_VERSION=${SW_VERSION:-"unknown"}
263313
[[ -d "$PROJECT_PATH/.git" && "$SW_NAME" = "unknown" ]] && SW_NAME=$(cd $PROJECT_PATH; basename -s .git `git config --get remote.origin.url`)
@@ -481,8 +531,8 @@ runs:
481531
-a $ORT_ADVISORS \
482532
-f JSON \
483533
${ORT_CLI_ADVISE_ARGS} || ORT_CLI_ADVISE_EXIT_CODE=$? \
484-
&& export ORT_CLI_ADVISE_EXIT_CODE="${ORT_CLI_ADVISE_EXIT_CODE:-0}" \
485-
&& printenv >> "$GITHUB_ENV"
534+
&& ORT_CLI_ADVISE_EXIT_CODE="${ORT_CLI_ADVISE_EXIT_CODE:-0}" \
535+
&& echo "exit-code=${ORT_CLI_EVALUATE_EXIT_CODE}" >> "$GITHUB_OUTPUT"
486536
[[ -f $ORT_RESULTS_ADVISOR_PATH ]] && \
487537
ln -frs $ORT_RESULTS_ADVISOR_PATH $ORT_RESULTS_CURRENT_PATH || \
488538
echo -e "\e[1;31m File $ORT_RESULTS_ADVISOR_PATH not found."
@@ -507,8 +557,8 @@ runs:
507557
-o ${ORT_RESULTS_PATH/$USER/ort} \
508558
-f JSON \
509559
${ORT_CLI_EVALUATE_ARGS} || ORT_CLI_EVALUATE_EXIT_CODE=$? \
510-
&& export ORT_CLI_EVALUATE_EXIT_CODE="${ORT_CLI_EVALUATE_EXIT_CODE:-0}" \
511-
&& printenv >> "$GITHUB_ENV"
560+
&& ORT_CLI_EVALUATE_EXIT_CODE="${ORT_CLI_EVALUATE_EXIT_CODE:-0}" \
561+
&& echo "exit-code=${ORT_CLI_EVALUATE_EXIT_CODE}" >> "$GITHUB_OUTPUT"
512562
[[ -f $ORT_RESULTS_EVALUATOR_PATH ]] && \
513563
ln -frs $ORT_RESULTS_EVALUATOR_PATH $ORT_RESULTS_CURRENT_PATH || \
514564
echo -e "\e[1;31m File $ORT_RESULTS_EVALUATOR_PATH not found."
@@ -565,7 +615,7 @@ runs:
565615
if: contains(inputs.run, 'upload-evaluation-result')
566616
with:
567617
name: "${{ env.ORT_RESULTS_ARTIFACT_NAME }}-evaluation-result.json.zip"
568-
path: ${{ env.ORT_RESULTS_EVALUATE_PATH }}
618+
path: ${{ env.ORT_RESULTS_EVALUATOR_PATH }}
569619
if-no-files-found: warn
570620
- name: Upload ORT scan-result.json
571621
uses: actions/upload-artifact@v4
@@ -575,13 +625,13 @@ runs:
575625
path: ${{ env.ORT_RESULTS_SCANNER_PATH }}
576626
if-no-files-found: warn
577627
- name: Conditionally fail action if returned violations from Evaluator exceeds severity threshold
578-
if: contains(inputs.fail-on, 'violations') && contains(env.ORT_CLI_EVALUATE_EXIT_CODE, 2)
628+
if: contains(inputs.fail-on, 'violations') && contains(steps.ort-evaluator.output.exit-code, 2)
579629
shell: bash
580630
run: |
581631
echo -e "\e[1;31m Failing action as Evaluator exceeded severity threshold... "
582632
exit 2
583633
- name: Conditionally fail action if returned issues from Advisor exceeds severity threshold
584-
if: contains(inputs.fail-on, 'issues') && contains(env.ORT_CLI_ADVISE_EXIT_CODE, 2)
634+
if: contains(inputs.fail-on, 'issues') && contains(steps.ort-advisor.output.exit-code, 2)
585635
shell: bash
586636
run: |
587637
echo -e "\e[1;31m Failing action as Advisor exceeded severity threshold... "

0 commit comments

Comments
 (0)