| 1 |
name: check-links |
| 2 |
on: |
| 3 |
push: |
| 4 |
branches: [main] |
| 5 |
pull_request: |
| 6 |
merge_group: |
| 7 |
types: [checks_requested] |
| 8 |
|
| 9 |
concurrency: |
| 10 |
group: ${{ github.workflow }}-${{ github.ref_name }} |
| 11 |
cancel-in-progress: true |
| 12 |
|
| 13 |
permissions: read-all |
| 14 |
|
| 15 |
jobs: |
| 16 |
changedfiles: |
| 17 |
name: changed files |
| 18 |
runs-on: ubuntu-latest |
| 19 |
env: |
| 20 |
PR_HEAD: ${{ github.event.pull_request.head.sha }} |
| 21 |
outputs: |
| 22 |
files: ${{ steps.changes.outputs.files }} |
| 23 |
steps: |
| 24 |
- name: Checkout Repo |
| 25 |
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 26 |
with: |
| 27 |
fetch-depth: 0 |
| 28 |
- name: Get changed files |
| 29 |
id: changes |
| 30 |
run: | |
| 31 |
files=$(git diff --name-only --diff-filter=ACMRTUXB $(git merge-base origin/main $PR_HEAD) $PR_HEAD | grep .md$ | xargs) |
| 32 |
|
| 33 |
if [ -z "$files" ] && git diff --name-only $(git merge-base origin/main $PR_HEAD) $PR_HEAD | grep -q "package.json"; then |
| 34 |
files="**/*.md" |
| 35 |
fi |
| 36 |
|
| 37 |
echo "files=$files" >> $GITHUB_OUTPUT |
| 38 |
check-links: |
| 39 |
runs-on: ubuntu-latest |
| 40 |
needs: changedfiles |
| 41 |
if: ${{needs.changedfiles.outputs.files}} |
| 42 |
steps: |
| 43 |
- name: Checkout Repo |
| 44 |
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 45 |
with: |
| 46 |
fetch-depth: 0 |
| 47 |
|
| 48 |
- name: Link Checker |
| 49 |
id: lychee |
| 50 |
uses: lycheeverse/lychee-action@a8c4c7cb88f0c7386610c35eb25108e448569cb0 # v2.7.0 |
| 51 |
with: |
| 52 |
args: "--verbose --no-progress ${{needs.changedfiles.outputs.files}} --config .github/lychee.toml" |
| 53 |
failIfEmpty: false |