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