update PR link checker workflow #129
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Link Checker for Pull requests | |
on: pull_request | |
jobs: | |
changedFiles: | |
runs-on: ubuntu-latest | |
outputs: | |
files: ${{ steps.changed-markdown-files.outputs.all_changed_files }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get changed markdown files | |
id: changed-markdown-files | |
uses: tj-actions/changed-files@v45 | |
with: | |
# Avoid using single or double quotes for multiline patterns | |
files: | | |
**.md | |
matrix: true | |
linkChecker: | |
runs-on: ubuntu-latest | |
needs: changedFiles | |
if: ${{ needs.changedFiles.outputs.files != '' && toJSON(fromJSON(needs.changedFiles.outputs.files)) != '[]' }} | |
strategy: | |
matrix: | |
file: ${{ fromJSON(needs.changedFiles.outputs.files) }} | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: download Lychee | |
run: | | |
wget https://github.com/lycheeverse/lychee/releases/download/nightly/lychee-x86_64-unknown-linux-gnu.tar.gz | |
tar xzf lychee-x86_64-unknown-linux-gnu.tar.gz | |
- name: Check all this file's additions for broken links | |
run: | | |
export base_sha=$(git rev-parse ${{ github.sha }}^) | |
git diff -U0 ${base_sha} ${{ github.event.pull_request.head.sha }} -- ${{ matrix.file }} | grep -v "+++" | grep "^+" | cut -c 2- | ./lychee - |