Skip to content

Commit

Permalink
Revert to old version of "failIfEmpty" check
Browse files Browse the repository at this point in the history
  • Loading branch information
mre committed Apr 25, 2024
1 parent 4b478a1 commit b5dcd3f
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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}"

Expand All @@ -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

0 comments on commit b5dcd3f

Please sign in to comment.