-
Notifications
You must be signed in to change notification settings - Fork 24
66 lines (58 loc) · 2.03 KB
/
Copy pathcheck-links.yml
File metadata and controls
66 lines (58 loc) · 2.03 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Check external links
on:
workflow_dispatch:
pull_request:
paths:
- '**.md'
- 'docs/**'
- '.github/workflows/check-links.yml'
- 'lychee.toml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
check-links:
name: Check external links in documentation
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v6
with:
persist-credentials: false
# To clear the lychee cache for a PR, replace `<pull-request-number>` with the PR number and run in pwsh:
# $ids = gh api repos/SteeltoeOSS/Documentation/actions/caches `
# --paginate `
# --jq '.actions_caches[]
# | select(.key | startswith("cache-lychee-<pull-request-number>-"))
# | .id'
# $ids | ForEach-Object {
# gh api -X DELETE "repos/SteeltoeOSS/Documentation/actions/caches/$_"
# Write-Host "Deleted cache $_"
# }
- name: Restore lychee cache
uses: actions/cache@v5
with:
path: .lycheecache
key: cache-lychee-${{ github.event.pull_request.number || 'manual' }}-${{ github.sha }}
restore-keys: cache-lychee-${{ github.event.pull_request.number || 'manual' }}-
- name: Check external links with lychee
uses: lycheeverse/lychee-action@v2
with:
args: --no-progress '**/*.md'
fail: false
failIfEmpty: true
jobSummary: false
- name: Add link checking results to job summary
run: |
if [ -f ./lychee/out.md ]; then
sed 's/^# Summary$/# External link checking results/' ./lychee/out.md | tee -a "$GITHUB_STEP_SUMMARY" > ./lychee/results.md
fi
- name: Comment on PR with link check results
if: ${{ github.event_name == 'pull_request' }}
uses: mshick/add-pr-comment@v3
with:
message-id: external-links-check
message-path: ./lychee/results.md