jnmetacode--agency-agents-zh
2f2f326011
原正则用两步 grep 提取链接,当 Markdown 链接文本包含括号时 (如 [SRE (站点可靠性工程师)](file.md))会误匹配文本中的括号, 导致误报 broken link。改用 lookbehind 单步提取 URL。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
63 行
2.2 KiB
YAML
63 行
2.2 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
validate:
|
|
name: Validate agent files
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Count agents
|
|
run: |
|
|
TOTAL=$(find . -path './.github' -prune -o -path './scripts' -prune -o -path './examples' -prune -o -path './integrations' -prune -o -name '*.md' -print | grep -c '/')
|
|
echo "Total agent files: $TOTAL"
|
|
|
|
- name: Check frontmatter format
|
|
run: |
|
|
ERRORS=0
|
|
while IFS= read -r file; do
|
|
# Skip non-agent files
|
|
case "$file" in
|
|
./README*|./CONTRIBUTING*|./UPSTREAM*|./AGENT-LIST*|./CATALOG*|./CODE_OF_CONDUCT*|./.github/*|./scripts/*|./examples/*|./integrations/*|./docs/*|./strategy/*) continue ;;
|
|
esac
|
|
|
|
# Check frontmatter exists
|
|
if ! head -1 "$file" | grep -q '^---'; then
|
|
echo "::error file=$file::Missing frontmatter (no opening ---)"
|
|
ERRORS=$((ERRORS + 1))
|
|
continue
|
|
fi
|
|
|
|
# Check required fields
|
|
FRONTMATTER=$(sed -n '/^---$/,/^---$/p' "$file" | head -20)
|
|
for field in name description; do
|
|
if ! echo "$FRONTMATTER" | grep -q "^${field}:"; then
|
|
echo "::warning file=$file::Missing recommended field: $field"
|
|
fi
|
|
done
|
|
done < <(find . -path './.github' -prune -o -path './scripts' -prune -o -path './examples' -prune -o -path './integrations' -prune -o -path './node_modules' -prune -o -name '*.md' -print | grep '/')
|
|
|
|
if [ $ERRORS -gt 0 ]; then
|
|
echo "::error::$ERRORS file(s) have frontmatter errors"
|
|
exit 1
|
|
fi
|
|
echo "All agent files validated successfully"
|
|
|
|
- name: Check for broken internal links
|
|
run: |
|
|
ERRORS=0
|
|
# Check README references to agent files
|
|
while read -r link; do
|
|
if [ ! -f "$link" ]; then
|
|
echo "::error file=README.md::Broken link: $link"
|
|
ERRORS=$((ERRORS + 1))
|
|
fi
|
|
done < <(grep -oP '(?<=\]\()(?!http)[^)]+\.md' README.md)
|
|
exit $ERRORS
|