Skip to content

Commit 2162420

Browse files
committed
test: detect when hugo server is ready and start checking
1 parent 6d7272a commit 2162420

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

.github/workflows/cron-check-int-links.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ jobs:
3939

4040
- name: Start Hugo server
4141
run: |
42-
nohup hugo server -p 1313 &
43-
sleep 5 # Wait for server to start
42+
hugo server --port 1313 >/dev/null 2>&1 &
43+
until curl -fs http://localhost:1313/ >/dev/null 2>&1; do
44+
sleep 0.2
45+
done
46+
echo "Hugo is ready"
4447
4548
- name: Check internal links
4649
id: linkcheck
@@ -50,18 +53,25 @@ jobs:
5053
/BROKEN/ { cluster=cluster $0 "\n"; next }
5154
/^Finished!/ { if(cluster) { printf "%s\n%s\n", header, cluster } }
5255
')
53-
echo ""
54-
echo "$broken"
56+
57+
printf "%s\n" "$broken"
58+
5559
echo "broken<<EOF" >> $GITHUB_ENV
5660
echo "$broken" >> $GITHUB_ENV
5761
echo "EOF" >> $GITHUB_ENV
5862
59-
- name: Stop Hugo server
60-
run: |
61-
pkill -f "hugo server"
63+
if [ -n "$broken" ]; then
64+
echo "Broken internal links detected"
65+
exit 1
66+
fi
6267
6368
- name: Suggestions
64-
if: env.broken != ''
69+
if: failure()
6570
run: |
6671
echo -e "\nPlease review the links reported in Check internal links step above.\n"
6772
exit 1
73+
74+
- name: Stop Hugo server
75+
if: always()
76+
run: |
77+
pkill -f "hugo server"

0 commit comments

Comments
 (0)