Skip to content

ci: Add script &CI to check dead links #35

ci: Add script &CI to check dead links

ci: Add script &CI to check dead links #35

name: Check Broken Links
on:
pull_request:
types: [opened, synchronize, reopened]
# 可选:添加定期检查
# schedule:
# - cron: "0 0 * * 0" # 每周日执行一次
jobs:
check-links:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup link exclusion patterns (optional)
id: setup-exclude
run: |
if [ -f .lycheeignore ]; then
echo "Exclusion patterns found in .lycheeignore"
else
echo "# 添加要排除的链接正则表达式,每行一个" > .lycheeignore
echo "# 例如:^https://example.com" >> .lycheeignore
fi
- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v2
env:
GITHUB_TOKEN: ${{ github.token }}
with:
args: --verbose --no-progress './**/*.md' './**/*.html' './**/*.txt'
fail: true
format: markdown
output: ./lychee-report.md
# 如果需要将检查结果作为PR评论发布,可以取消注释下面这一步
# - name: Create Comment
# uses: peter-evans/create-or-update-comment@v3
# if: github.event_name == 'pull_request' && steps.lychee.outputs.exit_code != 0
# with:
# issue-number: ${{ github.event.pull_request.number }}
# body-file: ./lychee-report.md