rupali-codes / LinksHub

LinksHub aims to provide developers with access to a wide range of free resources and tools that they can use in their work. These resources include links to free software, libraries, frameworks, and other tools that can be used to build and deploy applications and websites.
https://linkshub.dev
MIT License
682 stars 513 forks source link

[Feature] Broken Link Checker - Github Action #2357

Open JuanPabloDiaz opened 1 month ago

JuanPabloDiaz commented 1 month ago

Description

I believe that it will be a great idea to setup a GitHub action that runs periodically and checks for broken links.

I just implemented it in my project and I would like to share my knowledge and received feedback to make it better.

Screenshots

here is an example from my own project: image

Checklist

github-actions[bot] commented 1 month ago

2349, #2339, #2338, #2322 is already opened by you

As per contributing guidelines, you can only work on 1 issue at a time.

github-actions[bot] commented 1 month ago

Hello JuanPabloDiaz! Thank you for raising this issue! 😊 Your contribution is valuable to us! 😊

Please make sure to follow our Contributing Guidelines. 💪🏻

Please only work on an issue if you're assigned; otherwise, the PR will be automatically closed. Our review team will carefully assess the issue and reach out to you soon! 😇 We appreciate your patience!

CBID2 commented 1 month ago

That seems possible @JuanPabloDiaz. @rupali-codes, @Anmol-Baranwal, @aftabrehan, thoughts?

rupali-codes commented 1 month ago

That seems possible @JuanPabloDiaz. @rupali-codes, @Anmol-Baranwal, @aftabrehan, thoughts?

it seems great though, but how does that actually work @JuanPabloDiaz ?

JuanPabloDiaz commented 1 month ago

That seems possible @JuanPabloDiaz. @rupali-codes, @Anmol-Baranwal, @aftabrehan, thoughts?

it seems great though, but how does that actually work @JuanPabloDiaz ?

Github action to check for broken links in Markdown, HTML, and text files using Lychee, a fast link checker written in Rust.

Here is a full example of a GitHub workflow file:

It will check all repository links once per day and create an issue in case of errors.

name: Links

on:
  repository_dispatch:
  workflow_dispatch:
  schedule:
    - cron: "00 18 * * *"

jobs:
  linkChecker:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Link Checker
        id: lychee
        uses: lycheeverse/lychee-action@v1

      - name: Create Issue From File
        if: env.lychee_exit_code != 0
        uses: peter-evans/create-issue-from-file@v4
        with:
          title: Link Checker Report
          content-filepath: ./lychee/out.md
          labels: report, automated issue
Anmol-Baranwal commented 1 month ago

@rupali-codes

The URLs is in json files (this codebase), so maybe try this in a sample private repo to see if it works.

image

JuanPabloDiaz commented 1 month ago

Project implementations:

JuanPabloDiaz commented 1 month ago

I'd like to share my experience with Lychee. I came across it yesterday and integrated it into my project. While it was helpful in identifying some broken links, it also generated some false positives (links that appear broken but function correctly). I'm still exploring the tool's functionality to potentially fine-tune its accuracy.

On a separate note, I encountered a permissions issue when trying to open new issues.

I hope this helps

rupali-codes commented 1 month ago

@JuanPabloDiaz do you wanna work on it?

JuanPabloDiaz commented 1 month ago

@JuanPabloDiaz do you wanna work on it?

Sure. How can I test it? I understand that GitHub actions will need to be merge to see them in action. Is there a way to test them in development @rupali-codes ?

rupali-codes commented 1 month ago

@JuanPabloDiaz do you wanna work on it?

Sure. How can I test it? I understand that GitHub actions will need to be merge to see them in action. Is there a way to test them in development @rupali-codes ?

Yeah, we can test them in the forked repo

JuanPabloDiaz commented 1 month ago

You are absolutely right lol

But does it work from any branch, or does it have to be in the main branch of the forked repo @rupali-codes ?

JuanPabloDiaz commented 1 month ago

You are absolutely right lol

But does it work from any branch, or does it have to be in the main branch of the forked repo @rupali-codes ?

I figured it out. It has to be in the main brand of the forked repo

JuanPabloDiaz commented 1 month ago

Errors in CONTRIBUTING.md [404] https://github.com/CBID2/LinksHub-my-version-/blob/main/CODE_OF_CONDUCT.md | Failed: Network error: Not Found [404] https://github.com/rupali-codes/LinksHub/blob/maintainers_info/README.md#maintainers- | Failed: Network error: Not Found

image

JuanPabloDiaz commented 1 month ago

71? That number seems low.

I include JSON files in the link checker and the number went up to: https://github.com/JuanPabloDiaz/LinksHub/actions/runs/9306836967 image

JuanPabloDiaz commented 1 month ago

There are some false positive. After double checking the list of 29 errors. Here are some resources that should be removed:

  1. Errors in database/resources/e-book.json "name": "Learning REACT" [404] https://drive.google.com/file/d/1AZwshgVyazeIJ95ng6Pg1zUbVQoYX93t/view?usp=share_link | Failed: Network error: Not Found

  2. Errors in database/youtube/web-development.json "name": "Easy Tutorials" [404] https://www.youtube.com/@EasyTutorialsVideo/ | Failed: Network error: Not Found

  3. Errors in database/ai_tools/design.json "name": "Adobe Firefly" [TIMEOUT] https://www.adobe.com/in/products/firefly.html | Timeout "name": "Designs.ai", [ERR] https://designs.io/ | Failed: Network error: error sending request for url (https://designs.io/)

  4. Errors in database/youtube/web3-metaverse.json "name": "LearnWeb3 DAO" [404] https://www.youtube.com/@LearnWeb3DAO | Failed: Network error: Not Found

  5. Errors in database/frontend/colors.json "name": "ColorWave AI" [ERR] https://www.colorwave.dev/ | Failed: Network error: error sending request for url (https://www.colorwave.dev/) "name": "UI Color Picker" [ERR] https://uicolorpicker.com/ | Failed: Network error: error sending request for url (https://uicolorpicker.com/)

  6. Errors in database/resources/blogs.json "name": "JavaScript Tricks-Raj's Blog" [ERR] https://resourcegallery.live/blog/JavaScript%20Top%2010%20Tips%20&%20Tricks/ | Failed: Network error: error sending request for url (https://resourcegallery.live/blog/JavaScript%20Top%2010%20Tips%20&%20Tricks/)

  7. Errors in database/cybersecurity/web_application_security.json "name": "Certified Web Application Penetration Tester (CWAPT) Certification" [404] https://mile2.com/web-application-penetration-tester-cwapt.html | Failed: Network error: Not Found

CBID2 commented 1 month ago

You are absolutely right lol

But does it work from any branch, or does it have to be in the main branch of the forked repo @rupali-codes ?

It would be best to do it from the forked repository.

JuanPabloDiaz commented 2 days ago

May I have additional support here. I am not an expert with GitHub actions. How can I improve my workflow?