-
Notifications
You must be signed in to change notification settings - Fork 30
38 lines (37 loc) · 1.36 KB
/
link-checker-pr.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
31
32
33
34
35
36
37
38
name: Link Checker for Pull requests
on: pull_request
jobs:
changedFiles:
runs-on: ubuntu-latest
outputs:
files: ${{ steps.changed-markdown-files.outputs.all_changed_files }}
steps:
- uses: actions/checkout@v4
- name: Get changed markdown files
id: changed-markdown-files
uses: tj-actions/changed-files@v45
with:
# Avoid using single or double quotes for multiline patterns
files: |
**.md
matrix: true
linkChecker:
runs-on: ubuntu-latest
needs: changedFiles
if: ${{ needs.changedFiles.outputs.files != '' && toJSON(fromJSON(needs.changedFiles.outputs.files)) != '[]' }}
strategy:
matrix:
file: ${{ fromJSON(needs.changedFiles.outputs.files) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: download Lychee
run: |
wget https://github.com/lycheeverse/lychee/releases/download/nightly/lychee-x86_64-unknown-linux-gnu.tar.gz
tar xzf lychee-x86_64-unknown-linux-gnu.tar.gz
- name: Check all this file's additions for broken links
run: |
export base_sha=$(git rev-parse ${{ github.sha }}^)
git diff -U0 ${base_sha} ${{ github.event.pull_request.head.sha }} -- ${{ matrix.file }} | grep -v "+++" | grep "^+" | cut -c 2- | ./lychee -