You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Broken links are quite an annoyance for readers, and at least for links
that point to pages within the same static website, there are tools to
help identify those.
One such tool is called `lychee`. It has already a number of very useful
options and even sports a GitHub Action for easy integration into GitHub
workflows.
To accommodate the migration of https://git-scm.com/ from a Rails App to
a static site generated using Hugo, lychee was taught the trick needed
to support checking links in a static website with "pretty URLs" (i.e.
URLs lacking the `.html` file extension even though the files backing
those URLs do have that extension, something GitHub Pages supports).
With this mode, the automation that deploys https://git-scm.com/ can
make use of that link checker.
Seeing as broken links often originate from repositories outside of
https://github.com/git/git-scm.com's control, rather than failing
deployment when broken links are detected, let's follow the "best
effort" strategy and open a ticket about the broken links while still
letting the deployments complete.
In PR builds, links are also checked, and broken links will let them
fail.
While it was tempting to use a convenient GitHub Action like
`peter-evans/create-issue-from-file` to open the GitHub issue, there is
no readily-available Action to either open, update, or update & close
such a ticket, depending on the outcome of the link check and whether
such a ticket exists already and is open. Therefore, I opted for a more
verbose (and much more powerful) `actions/github-script` step to perform
this part of the job.
Based-on-feedback-by: Todd Zullinger <[email protected]>
Helped-by: Matthias Endler <[email protected]>
Helped-by: Thomas Zahner <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
description: The GitHub token used to create an authenticated client
15
+
default: ${{ github.token }}
16
+
required: true
12
17
outputs:
13
18
url:
14
19
description: The URL to which the site was deployed
@@ -62,3 +67,63 @@ runs:
62
67
- name: deploy
63
68
id: deploy
64
69
uses: actions/deploy-pages@v4
70
+
71
+
- name: construct `--remap` option for lychee
72
+
id: remap
73
+
shell: bash
74
+
run: |
75
+
base_url='${{ steps.pages.outputs.base_url }}'
76
+
echo "result=$(echo "$base_url" |
77
+
sed 's|^\(.*\)\(/git-scm\.com\)$|(\1)?\2(.*)|') file://$PWD/public\$2" \
78
+
>>$GITHUB_OUTPUT
79
+
80
+
- name: check for broken links
81
+
id: lychee
82
+
uses: lycheeverse/lychee-action@d4128702eae98bbc5ecf74df0165a8156c80920a # until an official version is out that includes https://github.com/lycheeverse/lychee/pull/1422
83
+
with:
84
+
lycheeVersion: nightly # until an official version includes https://github.com/lycheeverse/lychee/pull/1422
Copy file name to clipboardExpand all lines: .github/workflows/ci.yml
+19Lines changed: 19 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -57,3 +57,22 @@ jobs:
57
57
}
58
58
done
59
59
exit $res
60
+
61
+
- name: check for broken links
62
+
id: lychee
63
+
uses: lycheeverse/lychee-action@d4128702eae98bbc5ecf74df0165a8156c80920a # until an official version is out that includes https://github.com/lycheeverse/lychee/pull/1422
64
+
with:
65
+
lycheeVersion: nightly # until an official version includes https://github.com/lycheeverse/lychee/pull/1422
0 commit comments