GitHub Marketplace

A GitHub action for link checking repository Markdown and HTML files.

Note: I am not going to use this since the default gives an error as nothing on * and the expected subdirectory is not recognized. Perhaps this only works on a built site as that is an example where I saw this used.

Usage

Basic

  • main.yml ```yaml steps:
    • name: Link Checker uses: peter-evans/link-checker@v1 ```

Custom args

Optionally pass arguments to Liche. Defaults shown here.

  • main.yml
      steps:
        - name: Link Checker
          uses: peter-evans/link-checker@v1
          with:
            args: -v -r *
    

Note that even on verbose mode, nothing is outputted on a success so you canโ€™t see that any URLs were checked.

Create issues on error

When used in conjunction with Create Issue From File, issues will be created when Link Checker finds connectivity problems with links.

Based on the example from the Check Links docs.

  • main.yml
      name: Check markdown links
    
      on:
        schedule:
        - cron: '0 0 1 * *'
    
      jobs:
        link-checker:
          runs-on: ubuntu-latest
    
          steps:
            - uses: actions/checkout@v2
    
            - name: Link Checker
              uses: peter-evans/link-checker@v1
    
            - name: Create Issue From File
              uses: peter-evans/create-issue-from-file@v2
              with:
                title: Link Checker Report
                content-filepath: ./link-checker/out.md
                labels: report, automated issue
    

Fail on error

Add a step at the end.

  • main.yml
      steps:
        - name: Fail if there were link errors
          run: exit $
    

Run checks against output directory

This checks links the directory like site.

This runs against HTML files but it will still work.

source

  • main.yml
      steps:
      # Use liche action to check generated HTML site
        - name: Link Checker (generated site)
          id: lc
          uses: peter-evans/link-checker@v1
          with:
            args: -d site -r site -x man7.org
    
        - name: Fail on link errors
          run: exit ${{ steps.lc.outputs.exit_code }