-
-
Notifications
You must be signed in to change notification settings - Fork 72
55 lines (46 loc) · 1.58 KB
/
check-links.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Link Checker
on:
workflow_dispatch:
push:
branches:
- main
jobs:
link-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Lychee link checker on README.md
id: lychee_readme1
uses: lycheeverse/lychee-action@v2
with:
args: ./README.md
# - name: Run Lychee link checker on README2.md
# id: lychee_readme2
# uses: lycheeverse/lychee-action@v2
# with:
# args: ./README2.md
- name: Check for broken links
run: |
readme1_output="${{ steps.lychee_readme1.outputs.stdout }}"
# readme2_output="${{ steps.lychee_readme2.outputs.stdout }}"
readme1_broken=$(echo "$readme1_output" | grep -E '"fail":\s*[1-9]+')
# readme2_broken=$(echo "$readme2_output" | grep -E '"fail":\s*[1-9]+')
if [ -n "$readme1_broken" ]; then
echo "❌ Broken links found in README.md"
exit 1
else
echo "✅ No broken links found in README.md"
fi
- name: Notify user of broken links
if: failure()
uses: dawidd6/action-send-mail@v4
with:
server_address: smtp.gmail.com
server_port: 587
username: ${{ secrets.GMAIL_USERNAME }}
password: ${{ secrets.GMAIL_PASSWORD }}
subject: ❌ Broken links detected in README.md
body: '❌ Broken links were detected in README.md. Please check the workflow logs for details.'
from: [email protected]