validate-frontmatter.yml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. name: Validate Frontmatter
  2. on:
  3. pull_request:
  4. paths:
  5. - '**/agents/*.md'
  6. - '**/skills/*/SKILL.md'
  7. - '**/commands/*.md'
  8. jobs:
  9. validate:
  10. # Fork PRs are auto-closed by close-external-prs.yml, so skip validation
  11. # for them entirely. This also prevents untrusted filenames from forks
  12. # from ever reaching the shell steps below.
  13. if: github.event.pull_request.head.repo.full_name == github.repository
  14. runs-on: ubuntu-latest
  15. steps:
  16. - uses: actions/checkout@v4
  17. - uses: oven-sh/setup-bun@v2
  18. - name: Install dependencies
  19. run: cd .github/scripts && bun install yaml
  20. - name: Get changed frontmatter files
  21. id: changed
  22. env:
  23. GH_TOKEN: ${{ github.token }}
  24. PR_NUMBER: ${{ github.event.pull_request.number }}
  25. run: |
  26. # Use diff-filter=AMRC to exclude deleted files (D) - only Added, Modified, Renamed, Copied
  27. FILES=$(gh pr diff "$PR_NUMBER" --name-only --diff-filter=AMRC | grep -E '(agents/.*\.md|skills/.*/SKILL\.md|commands/.*\.md)$' || true)
  28. echo "files<<EOF" >> "$GITHUB_OUTPUT"
  29. echo "$FILES" >> "$GITHUB_OUTPUT"
  30. echo "EOF" >> "$GITHUB_OUTPUT"
  31. - name: Validate frontmatter
  32. if: steps.changed.outputs.files != ''
  33. env:
  34. FILES: ${{ steps.changed.outputs.files }}
  35. run: |
  36. printf '%s\n' "$FILES" | xargs bun .github/scripts/validate-frontmatter.ts