/urlchecker-action

:octocat: :link: GitHub action to extract and check urls in code and documentations.

Primary LanguageShellMIT LicenseMIT

GitHub Marketplace CodeFactor License

urlchecker-action

A GitHub action to collect and check URLs in a project (code and documentation). The action aims at detecting and reporting broken links.

How to use it?

A set of examples are included in the examples folder. A few detailed examples are also included below.

Example with Checkout

For most use cases, you will want to use the git repository that is being checked for a GitHub actions, and we do this by way of the actions/checkout action.

name: Check URLs

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: urls-checker
      uses: urlstechie/urlchecker-action@0.2.0
      with:
        # A subfolder or path to navigate to in the present or cloned repository
        subfolder: docs

        # A comma-separated list of file types to cover in the URL checks
        file_types: .md,.py,.rst

        # Choose whether to include file with no URLs in the prints.
        print_all: false

        # The timeout seconds to provide to requests, defaults to 5 seconds
        timeout: 5

        # How many times to retry a failed request (each is logged, defaults to 1)
        retry_count: 3

        # A comma separated links to exclude during URL checks
        white_listed_urls: https://github.com/SuperKogito/URLs-checker/issues/1,https://github.com/SuperKogito/URLs-checker/issues/2

        # A comma separated patterns to exclude during URL checks
        white_listed_patterns: https://github.com/SuperKogito/Voice-based-gender-recognition/issues

        # choose if the force pass or not
        force_pass : true

Example with Custom Clone

It could, however, be the case that you've set up a repository with one or more uses of the URLChecker that must clone one or more repos (possibly with varying branches) before doing the check. In this case, you might want to define git_path and branch for each section. An example is below:

name: Check URLs

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: URLs-checker
      uses: urlstechie/urlchecker-action@0.2.0
      with:
        # A project to clone. If not provided, assumes already cloned in the present working directory.
        git_path: https://github.com/urlstechie/URLs-checker-test-repo

        # If a git_path is defined to clone, clone this branch (defaults to master)
        branch: devel

        # A subfolder or path to navigate to in the present or cloned repository
        subfolder: docs

        # Delete the cloned repository after running URLchecked (default is false)
        cleanup: true

        # A comma-separated list of file types to cover in the URL checks
        file_types: .md,.py,.rst

        # Choose whether to include file with no URLs in the prints.
        print_all: false

        # The timeout seconds to provide to requests, defaults to 5 seconds
        timeout: 5

        # How many times to retry a failed request (each is logged, defaults to 1)
        retry_count: 3

        # A comma separated links to exclude during URL checks
        white_listed_urls: https://github.com/SuperKogito/URLs-checker/issues/1,https://github.com/SuperKogito/URLs-checker/issues/2

        # A comma separated patterns to exclude during URL checks
        white_listed_patterns: https://github.com/SuperKogito/Voice-based-gender-recognition/issues

        # A comma separated list of file patterns (direct paths work as well) to exclude
        white_listed_files: README.md,/github/workspace/_config.yml

        # choose if the force pass or not
        force_pass : true

Inputs

variable name variable type variable description
git_path optional A git url to clone, if the repository isn't already in $PWD
branch optional If we do a clone, clone this branch (defaults to master
cleanup optional If we do a clone, delete the cloned folder after (false)
subfolder optional A subfolder to navigate to in the repository to check
file_types optional A comma-separated list of file types to cover in the URLs checks.
include_files optional A comma-separated list of exact files to check.
print_all optional Choose whether to include file with no URLs in the prints.
retry_count optional If a request fails, retry this number of times. Defaults to 1
save optional A path to a csv file to save results to
timeout optional The timeout to provide to requests to wait for a response.
white_listed_urls optional A comma separated links to exclude during URL checks.
white_listed_patterns optional A comma separated patterns to exclude during URL checks.
white_listed_files optional Full paths to files to exclude (comma separated list).
force_pass optional Choose whether to force a pass when checks are done.

Demo

  • Using version > 0.1.4

  • Using version =< 0.1.4

Support

Do you have a question or an issue? Please open an issue and we can help! The following communities are using the url checker! You can look here for examples or inspiration. If you want to add your community, please let us know with an issue.

Repository Workflow (with permalink to YAML) Example runs
awesome-rseng Check URLs in PRs, whitelists docs Logs
buildtest Check URLs in all commits Logs
us-rse Check URLs in PRs, whitelists some URL patterns Logs
R-hub docs Check URLs when on PR labelling Logs