-
Notifications
You must be signed in to change notification settings - Fork 103
30 lines (28 loc) · 1.17 KB
/
url-checking.yml
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
29
30
name: 'URL Checker'
on: [push, pull_request]
jobs:
check_urls:
runs-on: ubuntu-latest
steps:
- name: Checkout git repo
uses: actions/[email protected]
- name: Download and install Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: "0.82.0"
extended: true
- name: Update link shortcode to error on broken links
run: sed -i 's/#ERROR/\<{{ errorf "broken link in %s" .Position }}\>/g' themes/netDocs/layouts/shortcodes/link.html
- name: Run Hugo
run: hugo
# There is a bug in the checkout module. If the output of this is too long (without head) it will cause the checkout "cleanup"
# step to fail. This will cause the action to declare a build failure.
- name: Grep for bad kb_links
run: |
echo "GREP_OUTPUT<<EOF" >> $GITHUB_ENV
grep -ro --exclude='*/pdf/index.html' --exclude="*.txt" --include='*.html' '<code><a rel="canonical" href="' public/ | head -20 >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Print bad kb_links
run: echo $GREP_OUTPUT
- name: Exit != 0 if there was grep output
run: exit $(echo -n $GREP_OUTPUT | wc -m)