How to set up GitHub Actions to automatically check links in README.md? #181669
-
Why are you starting this discussion?Question What GitHub Actions topic or product is this about?Misc Discussion DetailsHi everyone, I'm maintaining a repository with a curated list of APIs in README.md. The list is growing and I want to automatically check if any links become broken. What I need:
I've seen some link checker actions but I'm not sure which one to use or how to configure it properly. Any help would be appreciated! 🙏 |
BetaWas this translation helpful?Give feedback.
Replies: 2 comments
-
SolutionCreate a new file name: Check Links jobs: How it works:
This is the recommended approach for link checking in GitHub Actions. Hope this helps! |
BetaWas this translation helpful?Give feedback.
-
Hi @minx-nie, Great question! Here's a complete solution for automated link checking: Option 1: Using lychee (Recommended)Create .github/workflows/link-checker.yml: name: Link Checkeron: schedule: - cron: '0 0 * * 0'# Every Sunday at midnightworkflow_dispatch: # Allow manual triggerjobs: check-links: runs-on: ubuntu-lateststeps: - uses: actions/checkout@v4 - name: Check Linksuses: lycheeverse/lychee-action@v1with: args: --verbose --no-progress README.mdfail: true - name: Create Issue on Failureif: failure()uses: actions/github-script@v7with: script: | github.rest.issues.create({ owner: context.repo.owner, repo: context.repo.repo, title: '🔗 Broken links detected', body: 'The link checker found broken links. Check the workflow run for details.' })Option 2: Custom Python ScriptFor more control, you can write a custom script that:
Key Tips:
Hope this helps! 🚀 |
BetaWas this translation helpful?Give feedback.
Hi @minx-nie,
Great question! Here's a complete solution for automated link checking:
Option 1: Using lychee (Recommended)
Create .github/workflows/link-checker.yml: