forked from peter-evans/link-checker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·28 lines (22 loc) · 967 Bytes
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh -l
set -uo pipefail
LINKCHECKER_OUTPUT_DIR=${LINKCHECKER_OUTPUT_DIR:="link-checker"}
LINKCHECKER_OUTPUT_FILENAME=${LINKCHECKER_OUTPUT_FILENAME:="out.md"}
# Make the temp directory
mkdir -p /tmp/link-checker
# Execute Liche
liche $* >/tmp/link-checker/out 2>&1
exit_code=$?
# If link errors were found output a report to the designated directory
if [ $exit_code -eq 1 ]; then
mkdir -p $LINKCHECKER_OUTPUT_DIR
echo -e '### Link Checker\nErrors were reported while checking the connectivity of links.\n```' \
>$LINKCHECKER_OUTPUT_DIR/$LINKCHECKER_OUTPUT_FILENAME
cat /tmp/link-checker/out >>$LINKCHECKER_OUTPUT_DIR/$LINKCHECKER_OUTPUT_FILENAME
echo '```' >>$LINKCHECKER_OUTPUT_DIR/$LINKCHECKER_OUTPUT_FILENAME
echo "Link checker output file: $LINKCHECKER_OUTPUT_DIR/$LINKCHECKER_OUTPUT_FILENAME"
fi
# Output to console
cat /tmp/link-checker/out
# Pass Liche exit code to next step
echo ::set-output name=exit_code::$exit_code