Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2
Move frontmatter schema to subfolder#58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Workflow artifacts and logs | ||
| validation-errors.log | ||
| *.log |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| --- | ||
| name: Frontmatter Validation | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - develop | ||
| - 'claude/**' | ||
| paths: | ||
| - '**.md' | ||
| - 'schemas/frontmatter/**' | ||
| - '.github/workflows/frontmatter-validation.yml' | ||
| pull_request: | ||
| paths: | ||
| - '**.md' | ||
| - 'schemas/frontmatter/**' | ||
| - '.github/workflows/frontmatter-validation.yml' | ||
| workflow_dispatch: | ||
| jobs: | ||
| validate-schema: | ||
| name: Validate Frontmatter Schema | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pin actions to commit SHAs instead of mutable tags. The workflow uses mutable version tags (@v4) for actions, which can be updated and potentially introduce supply-chain vulnerabilities. Pin all actions to full-length commit SHAs. As per coding guidelines, find the commit SHAs for these versions and pin them: #!/bin/bash# Find latest commit SHAs for the actions in useecho"=== actions/checkout@v4 ==="
gh api repos/actions/checkout/git/ref/tags/v4 | jq -r '.object.sha'echo"=== actions/setup-node@v4 ==="
gh api repos/actions/setup-node/git/ref/tags/v4 | jq -r '.object.sha'echo"=== actions/upload-artifact@v4 ==="
gh api repos/actions/upload-artifact/git/ref/tags/v4 | jq -r '.object.sha'echo"=== tj-actions/changed-files@v44 ==="
gh api repos/tj-actions/changed-files/git/ref/tags/v44 | jq -r '.object.sha'echo"=== actions/github-script@v7 ==="
gh api repos/actions/github-script/git/ref/tags/v7 | jq -r '.object.sha'Also applies to: 56-56, 88-88 🤖 Prompt for AI Agents | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'npm' | ||
| cache-dependency-path: schemas/frontmatter/package-lock.json | ||
| - name: Install dependencies | ||
| working-directory: schemas/frontmatter | ||
| run: npm ci | ||
| - name: Validate schema structure | ||
| working-directory: schemas/frontmatter | ||
| run: npm run validate:schema | ||
| - name: Run schema tests | ||
| working-directory: schemas/frontmatter | ||
| run: npm test | ||
| validate-frontmatter: | ||
| name: Validate All Frontmatter | ||
| runs-on: ubuntu-latest | ||
| needs: validate-schema | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'npm' | ||
| cache-dependency-path: schemas/frontmatter/package-lock.json | ||
| - name: Install dependencies | ||
| working-directory: schemas/frontmatter | ||
| run: npm ci | ||
| - name: Validate all frontmatter files | ||
| working-directory: schemas/frontmatter | ||
| run: npm run validate | ||
| - name: Upload validation report | ||
| if: failure() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: validation-errors | ||
| path: schemas/frontmatter/validation-errors.log | ||
| retention-days: 7 | ||
| frontmatter-changed-files: | ||
| name: Validate Changed Files Only | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'pull_request' | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'npm' | ||
| cache-dependency-path: schemas/frontmatter/package-lock.json | ||
| - name: Install dependencies | ||
| working-directory: schemas/frontmatter | ||
| run: npm ci | ||
| - name: Get changed markdown files | ||
| id: changed-files | ||
| uses: tj-actions/changed-files@v44 | ||
| with: | ||
| files: | | ||
| **.md | ||
| - name: Validate changed files | ||
| if: steps.changed-files.outputs.any_changed == 'true' | ||
| working-directory: schemas/frontmatter | ||
| run: | | ||
| echo "Validating changed files:" | ||
| for file in ${{ steps.changed-files.outputs.all_changed_files }}; do | ||
| echo " - $file" | ||
| node validate.js "../../$file" || exit 1 | ||
| done | ||
| - name: Comment on PR | ||
| if: failure() && github.event_name == 'pull_request' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: '⚠️ **Frontmatter validation failed**\n\nPlease check the workflow logs for details and ensure all frontmatter follows the schema at `schemas/frontmatter/frontmatter.schema.json`.\n\nSee [Frontmatter Documentation](https://github.com/lightspeedwp/.github/blob/develop/schemas/frontmatter/README.md) for guidance.' | ||
| }) | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add explicit permissions and concurrency controls.
The workflow is missing two critical GitHub Actions best practices:
permissionskey to follow the principle of least privilegeconcurrencykey to prevent overlapping runs and save CI resourcesAs per coding guidelines, apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents