Skip to content

fix(site): show tombstone notices in finder results and single-source the banner copy #182

fix(site): show tombstone notices in finder results and single-source the banner copy

fix(site): show tombstone notices in finder results and single-source the banner copy #182

Workflow file for this run

name: Links
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
issues: write
jobs:
linkcheck:
runs-on: ubuntu-latest
if: github.repository == 'textrefs/textrefs.org'
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
# Extract external URLs directly from sources instead of crawling the
# built site. The rendered site expands each citation system into one
# resolver URL per reference (~200k URLs for ~10 works), but every
# distinct target already appears in the YAML source. Internal links,
# anchors, and i18n are validated at build time by
# starlight-links-validator, so this workflow only checks externals.
- name: Collect external URLs from sources
run: |
mkdir -p lychee
# A URL may legitimately contain `(` and `)`, because Wikipedia and
# Wikisource put disambiguation titles there. The match therefore
# keeps parentheses and the trailing markup is trimmed afterwards.
#
# The trim runs as one loop, not as a fixed sequence. A URL at the
# end of a markdown link, a bold run, or a sentence carries several
# layers of trailing markup at once — `…/4.0/).`, `…/arks.org/)**`,
# `…/rfc3987))` — so each pass strips punctuation, then one
# unbalanced `)`, until the string stops changing. Doing this in a
# single pass leaves a `)` behind whenever punctuation follows it,
# which is what produced the false 404s in #3.
#
# Resolver templates are dropped: `{placeholder}` literally, and
# `%7B`/`%7D` for the percent-encoded spelling.
#
# Restrict to YAML/MD, and skip node_modules, so lockfiles and
# dependency READMEs inside data/ are not scanned.
grep -rhoE --include='*.yaml' --include='*.yml' --include='*.md' --include='*.mdx' \
--exclude-dir=node_modules \
'https?://[^]["'\''<>[:space:]]+' data/ src/content/docs/ \
| awk '{
do {
changed = 0
if (sub(/[.,;:!?*_`]+$/, "")) changed = 1
n = gsub(/\(/, "&"); m = gsub(/\)/, "&")
if (m > n && sub(/\)$/, "")) changed = 1
} while (changed)
if (length($0) > 0) print
}' \
| grep -viE '[{}]|%7b|%7d' \
| sort -u > lychee/urls.txt
echo "Collected $(wc -l < lychee/urls.txt) unique URLs"
- name: Check links with lychee
id: lychee
uses: lycheeverse/lychee-action@v2
with:
args: --config lychee.toml lychee/urls.txt
output: ./lychee/out.md
fail: false
# Report only: never fail CI. On main (or manual dispatch) open/update a
# tracking issue when broken links are found. PR runs only show the job summary.
- name: Create or update link report issue
if: >-
steps.lychee.outputs.exit_code != 0 &&
(github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch')
uses: peter-evans/create-issue-from-file@v6
with:
title: Link Checker Report
content-filepath: ./lychee/out.md
labels: report, automated