2
2
set -uo pipefail
3
3
4
4
# Enable optional debug output
5
- if [ " ${INPUT_DEBUG} " = " true" ]; then
5
+ if [ " ${INPUT_DEBUG} " = true ]; then
6
6
echo " Debug output enabled"
7
7
set -x
8
8
fi
@@ -25,11 +25,7 @@ FORMAT=""
25
25
eval lychee ${FORMAT} --output ${LYCHEE_TMP} ${ARGS}
26
26
exit_code=$?
27
27
28
- if [ ! -f " ${LYCHEE_TMP} " ]; then
29
- echo " No output. Check pipeline run to see if lychee panicked." > " ${LYCHEE_TMP} "
30
- fi
31
-
32
- # Overwrite the error code in case no links were found
28
+ # Overwrite the exit code in case no links were found
33
29
# and `fail-if-empty` is set to `true` (and it is by default)
34
30
if [ " ${INPUT_FAILIFEMPTY:- false} " = " true" ]; then
35
31
# This is a somewhat crude way to check the Markdown output of lychee
@@ -40,8 +36,10 @@ if [ "${INPUT_FAILIFEMPTY:-false}" = "true" ]; then
40
36
fi
41
37
fi
42
38
43
- # If link errors were found, create a report in the designated directory
44
- if [ $exit_code -ne 0 ]; then
39
+ if [ ! -f " ${LYCHEE_TMP} " ]; then
40
+ echo " No output. Check pipeline run to see if lychee panicked." > " ${LYCHEE_TMP} "
41
+ else
42
+ # If we have any output, create a report in the designated directory
45
43
mkdir -p " $( dirname -- " ${INPUT_OUTPUT} " ) "
46
44
cat " ${LYCHEE_TMP} " > " ${INPUT_OUTPUT} "
47
45
@@ -55,16 +53,16 @@ cat "${LYCHEE_TMP}"
55
53
echo
56
54
57
55
if [ " ${INPUT_FORMAT} " == " markdown" ]; then
58
- if [ " ${INPUT_JOBSUMMARY} " = " true" ]; then
56
+ if [ " ${INPUT_JOBSUMMARY} " = true ]; then
59
57
cat " ${LYCHEE_TMP} " > " ${GITHUB_STEP_SUMMARY} "
60
58
fi
61
59
fi
62
60
63
61
# Pass lychee exit code to next step
64
- echo " lychee_exit_code=$exit_code " >> " $GITHUB_ENV "
62
+ echo " lychee_exit_code=$exit_code " >> $GITHUB_ENV
65
63
66
64
# If `fail` is set to `true`, propagate the real exit code to the workflow
67
65
# runner. This will cause the pipeline to fail on `exit != 0`.
68
- if [ " ${ INPUT_FAIL} " = " true" ] ; then
66
+ if [ " $INPUT_FAIL " = true ] ; then
69
67
exit ${exit_code}
70
68
fi
0 commit comments