Skip to content

chore: add cf.add and cf.addnx docs #285

chore: add cf.add and cf.addnx docs

chore: add cf.add and cf.addnx docs #285

Workflow file for this run

name: Check Markdown Links
on:
pull_request:
paths:
- 'docs/**'
- '*.md'
schedule:
# Run daily at 6:00 UTC
- cron: '0 6 * * *'
workflow_dispatch: # Allow manual trigger
jobs:
check-links:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install markdown-link-check
run: npm install -g markdown-link-check
- name: Create config
run: |
cat > .mlc-config.json << 'EOF'
{
"ignorePatterns": [{ "pattern": "^/" }, { "pattern": "^#" }, { "pattern": "localhost" }],
"httpHeaders": [
{
"urls": ["https://"],
"headers": {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
}
}
],
"timeout": "20s",
"retryOn429": true,
"retryCount": 5,
"aliveStatusCodes": [200, 201, 202, 203, 204, 206, 301, 302, 303, 307, 308, 400, 403, 429]
}
EOF
- name: Check links in all markdown files
env:
FORCE_COLOR: 1
run: |
# Create a temporary file to collect all broken links
broken_links_report=$(mktemp)
trap 'rm -f "$broken_links_report"' EXIT
files_checked=0
files_with_errors=0
while IFS= read -r file; do
files_checked=$((files_checked + 1))
# Run markdown-link-check and capture output and exit code
set +e
output=$(markdown-link-check --config .mlc-config.json "$file" 2>&1)
exit_code=$?
set -e
# Print the full output for each file
echo "$output"
echo ""
# Check if there are any broken links using exit code
if [ $exit_code -ne 0 ]; then
files_with_errors=$((files_with_errors + 1))
echo "" >> "$broken_links_report"
echo "📄 $file" >> "$broken_links_report"
echo "$output" >> "$broken_links_report"
fi
done < <(find docs -name "*.md" -type f)
echo ""
echo "=========================================="
echo "📊 Link Check Summary"
echo "=========================================="
echo "Files checked: $files_checked"
if [ "$files_with_errors" -gt 0 ]; then
echo "Files with broken links: $files_with_errors"
echo ""
echo "=========================================="
echo "❌ Broken Links Report"
echo "=========================================="
cat "$broken_links_report"
echo ""
echo "=========================================="
echo "::error::Found broken links in $files_with_errors file(s)!"
exit 1
fi
echo "✅ All links are valid!"
- name: Send notification on failure
if: failure() && github.ref == 'refs/heads/main'
run: |
job_link="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
message="Link check failed in documentation.\nJob Link: ${job_link}"
curl -s \
-X POST \
-H 'Content-Type: application/json' \
'${{ secrets.GSPACES_BOT_DF_BUILD }}' \
-d '{"text": "'"${message}"'"}'