-
Notifications
You must be signed in to change notification settings - Fork 114
87 lines (74 loc) · 2.97 KB
/
Copy pathfern-docs-ci.yml
File metadata and controls
87 lines (74 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# Validates Fern configuration and checks for broken links on pull requests
# that touch docs/** or fern/** files.
name: Fern Docs (CI)
on:
push:
branches:
- "pull-request/[0-9]+"
workflow_dispatch:
permissions:
contents: read
jobs:
changed-files:
runs-on: linux-amd64-cpu32
outputs:
docs: ${{ steps.changes.outputs.docs }}
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Check for docs changes
id: changes
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "docs=true" >> $GITHUB_OUTPUT
elif [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then
echo "docs=true" >> $GITHUB_OUTPUT
elif git diff --name-only "${{ github.event.before }}" HEAD 2>/dev/null | grep -qE '^(docs/|fern/)'; then
echo "docs=true" >> $GITHUB_OUTPUT
else
echo "docs=false" >> $GITHUB_OUTPUT
fi
fern-check:
name: Fern Configuration Check
needs: changed-files
if: needs.changed-files.outputs.docs == 'true'
runs-on: linux-amd64-cpu32
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '20'
- name: Install Fern CLI
run: npm install -g fern-api@$(jq -r .version fern/fern.config.json)
- name: Check MDX safety
# Intentionally inline — a composite action would add indirection without benefit for a single grep.
run: |
BAD=$(grep -rn '<img\b[^>]*[^/]>\|<img>' docs/ fern/ --include="*.md" --include="*.mdx" || true)
if [ -n "$BAD" ]; then
echo "::error::Non-self-closing <img> tags found (MDX requires <img ... />):"
echo "$BAD"
exit 1
fi
- name: Validate Fern configuration
run: fern check
- name: Warn on non-lowercase or underscore markdown filenames
# TODO: convert to a hard failure once existing violations are resolved
run: |
find docs/ -name "*.md" | while read f; do
base=$(basename "$f")
if echo "$base" | grep -qE '[A-Z]|_'; then
suggested=$(echo "$base" | tr '[:upper:]' '[:lower:]' | tr '_' '-')
echo "::warning file=$f::Filename '$base' should be lowercase with hyphens (e.g. '$suggested')"
fi
done
- name: Check for broken links
uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 # v2.9.0
with:
args: --offline --no-progress 'docs/**/*.md'
fail: true