Skip to content

Directory Docs Restructure #229

Directory Docs Restructure

Directory Docs Restructure #229

Workflow file for this run

# SPDX-FileCopyrightText: Copyright (c) 2026 Cisco and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
name: Check links in diffs
on:
pull_request:
types: [opened, synchronize, reopened]
branches: [main, master]
workflow_dispatch:
jobs:
check-links:
runs-on: ubuntu-latest
steps:
- name: Clone repository (PR)
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: 'recursive'
- name: Clone repository (manual)
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: '1.23.1'
- name: Setup Task
uses: arduino/setup-task@v2
with:
version: '3.48.0'
- name: Setup UV
shell: bash
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Update GITHUB_PATH
shell: bash
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Build docs
shell: bash
run: task build
- name: Fetch base branch
if: github.event_name == 'pull_request'
run: |
git remote add upstream https://github.com/${{ github.repository }}.git 2>/dev/null || true
git fetch upstream ${{ github.event.pull_request.base.ref }}
- name: Get paths to check
id: get_paths
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "paths=.build/site" >> $GITHUB_OUTPUT
echo "has_paths=true" >> $GITHUB_OUTPUT
exit 0
fi
BASE=$(git merge-base FETCH_HEAD HEAD)
changed=$(git diff --name-only $BASE...HEAD -- docs/)
paths=""
for f in $changed; do
[ -z "$f" ] && continue
# Skip non-.md files (e.g. awesome-pages .index); lychee cannot parse them
case "$f" in *.md) ;; *) continue ;; esac
if [ "$f" = "docs/index.md" ]; then
paths="$paths .build/site/index.html"
else
path="${f#docs/}"
path="${path%.md}"
paths="$paths .build/site/${path}/"
fi
done
paths=$(echo $paths)
echo "paths=$paths" >> $GITHUB_OUTPUT
[ -n "$paths" ] && echo "has_paths=true" >> $GITHUB_OUTPUT || echo "has_paths=false" >> $GITHUB_OUTPUT
- name: Remove paths lychee cannot parse
if: steps.get_paths.outputs.has_paths == 'true'
run: |
find .build/site -name '.index' -type f -delete
find .build/site -depth -name '.index' -type d -exec rm -rf {} \;
- name: Check links
if: steps.get_paths.outputs.has_paths == 'true'
uses: lycheeverse/lychee-action@v2.0.2 # CVE-2024-48908: pin >=2.0.2
with:
lycheeVersion: "v0.22.0" # v0.16.x (action default) does not support --root-dir; added in v0.18
args: |
--no-progress
--config lychee.toml
--root-dir $PWD/.build/site
--exclude-all-private
--remap 'https://docs\.agntcy\.org/(.*)/ file://'$PWD'/.build/site/$1/index.html'
${{ steps.get_paths.outputs.paths }}
fail: true
output: lychee/out.md
- name: Suggestions
if: failure()
run: |
echo -e "\nPlease review the links reported in the Check links step above."
echo -e "If a link is valid but fails due to a CAPTCHA challenge, IP blocking, login requirements, etc.,"
echo -e "consider adding such links to lychee.toml exclude list to bypass future checks.\n"
exit 1