Skip to content

Commit 123efbf

Browse files
janhohenheimbash
andauthored
Check for dead links (#1486)
Co-authored-by: Tau Gärtli <[email protected]>
1 parent b06b4ec commit 123efbf

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

.github/workflows/ci.yml

+31-4
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,43 @@ jobs:
1515
# https://github.com/crazy-max/ghaction-github-pages/issues/1#issuecomment-623202206
1616
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
21+
- name: Get changed files
22+
id: changed-files
23+
# source: https://stackoverflow.com/a/74268200, added filtering for markdown files
24+
run: |
25+
if ${{ github.event_name == 'pull_request' }}; then
26+
changed_files=$(git diff --name-only -r HEAD^1 HEAD -z | grep '\.md$' -zZ | xargs -0)
27+
else
28+
changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} -z | grep '\.md$' -zZ | xargs -0)
29+
fi
30+
echo "changed_files: $changed_files"
31+
echo "changed_files=$changed_files" >> $GITHUB_OUTPUT
1932
- name: Lint
2033
uses: avto-dev/markdown-lint@v1
2134
with:
2235
args: '.'
2336
config: '.markdownlint.json'
37+
- name: Check links
38+
uses: lycheeverse/[email protected]
39+
if: ${{ steps.changed-files.outputs.changed_files != '' }}
40+
with:
41+
fail: true
42+
args: >-
43+
--verbose
44+
--no-progress
45+
--accept '100..=103,200..=299,300..=399'
46+
--exclude '[^\w]todo[^\w]?'
47+
--exclude 'https://(www\.|old\.)?reddit\.com'
48+
${{ steps.changed-files.outputs.changed_files }}
2449
- name: Install Zola
25-
run: curl -L ${BASE_URL}/${VERS}/zola-${VERS}-${ARCH}.tar.gz | tar -xz
26-
- run: ./zola --version
27-
- run: ./zola build
50+
run: |
51+
curl -L ${BASE_URL}/${VERS}/zola-${VERS}-${ARCH}.tar.gz | tar -xz
52+
echo "Zola version: $(./zola --version)"
53+
- name: Zola build
54+
run: ./zola build
2855
- name: Deploy
2956
if: github.ref == 'refs/heads/source'
3057
uses: crazy-max/ghaction-github-pages@v1

0 commit comments

Comments
 (0)