From eb1a7d323c4c74e526f6f63e173816bbe499d22e Mon Sep 17 00:00:00 2001 From: Matthias Endler Date: Thu, 25 Apr 2024 13:27:55 +0200 Subject: [PATCH] Revert to old version of "failIfEmpty" check --- action.yml | 20 +++++--------------- entrypoint.sh | 20 +++++++++----------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/action.yml b/action.yml index f53d9d0..c5b49b4 100644 --- a/action.yml +++ b/action.yml @@ -7,26 +7,16 @@ inputs: required: false debug: description: "Enable debug output in action (set -x). Helpful for troubleshooting." - format: - description: "output format (e.g. json)" - default: "markdown" - required: false - output: - description: "output file" - default: "lychee/out.md" + default: false required: false - failIfEmpty: - description: "fail entire pipeline if no links were found" - default: true + fail: + description: "Fail entire pipeline on error (i.e. when lychee exit code is not 0)" + default: false required: false failIfEmpty: description: "fail entire pipeline if no links were found" default: true required: false - fail: - description: "Fail entire pipeline on error (i.e. when lychee exit code is not 0)" - default: false - required: false format: description: "Summary output format (e.g. json)" default: "markdown" @@ -80,4 +70,4 @@ runs: shell: bash branding: icon: "external-link" - color: "purple" + color: "purple" \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index aeff644..3459510 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,7 +2,7 @@ set -uo pipefail # Enable optional debug output -if [ "${INPUT_DEBUG}" = "true" ]; then +if [ "${INPUT_DEBUG}" = true ]; then echo "Debug output enabled" set -x fi @@ -25,11 +25,7 @@ FORMAT="" eval lychee ${FORMAT} --output ${LYCHEE_TMP} ${ARGS} exit_code=$? -if [ ! -f "${LYCHEE_TMP}" ]; then - echo "No output. Check pipeline run to see if lychee panicked." > "${LYCHEE_TMP}" -fi - -# Overwrite the error code in case no links were found +# Overwrite the exit code in case no links were found # and `fail-if-empty` is set to `true` (and it is by default) if [ "${INPUT_FAILIFEMPTY:-false}" = "true" ]; then # This is a somewhat crude way to check the Markdown output of lychee @@ -40,8 +36,10 @@ if [ "${INPUT_FAILIFEMPTY:-false}" = "true" ]; then fi fi -# If link errors were found, create a report in the designated directory -if [ $exit_code -ne 0 ]; then +if [ ! -f "${LYCHEE_TMP}" ]; then + echo "No output. Check pipeline run to see if lychee panicked." > "${LYCHEE_TMP}" +else + # If we have any output, create a report in the designated directory mkdir -p "$(dirname -- "${INPUT_OUTPUT}")" cat "${LYCHEE_TMP}" > "${INPUT_OUTPUT}" @@ -55,16 +53,16 @@ cat "${LYCHEE_TMP}" echo if [ "${INPUT_FORMAT}" == "markdown" ]; then - if [ "${INPUT_JOBSUMMARY}" = "true" ]; then + if [ "${INPUT_JOBSUMMARY}" = true ]; then cat "${LYCHEE_TMP}" > "${GITHUB_STEP_SUMMARY}" fi fi # Pass lychee exit code to next step -echo "lychee_exit_code=$exit_code" >> "$GITHUB_ENV" +echo "lychee_exit_code=$exit_code" >> $GITHUB_ENV # If `fail` is set to `true`, propagate the real exit code to the workflow # runner. This will cause the pipeline to fail on `exit != 0`. -if [ "${INPUT_FAIL}" = "true" ]; then +if [ "$INPUT_FAIL" = true ] ; then exit ${exit_code} fi