.github/workflows/validate-frontmatter.yml #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate Frontmatter | |
| on: | |
| schedule: | |
| # Run nightly at 06:00 UTC | |
| - cron: '0 6 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| issues: write | |
| concurrency: | |
| group: frontmatter-validation | |
| cancel-in-progress: false | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Validate frontmatter against Featurebase | |
| id: validate | |
| env: | |
| FEATUREBASE_API_KEY: ${{ secrets.FEATUREBASE_API_KEY }} | |
| continue-on-error: true | |
| run: node scripts/validate-frontmatter.mjs | |
| - name: Create issue on mismatch | |
| if: steps.validate.outcome == 'failure' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Check if an open issue already exists | |
| EXISTING=$(gh issue list --label "frontmatter-mismatch" --state open --json number --jq '.[0].number // empty') | |
| BODY="## Frontmatter Validation Failed | |
| The nightly frontmatter check found mismatches between local docs and Featurebase. | |
| **Issues found:** ${{ steps.validate.outputs.issue_count || 'see logs' }} | |
| ${{ steps.validate.outputs.issues || 'Check workflow logs for details.' }} | |
| **Action required:** Review and fix the frontmatter to match Featurebase. | |
| --- | |
| _Generated by [validate-frontmatter](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) workflow_" | |
| if [ -n "$EXISTING" ]; then | |
| echo "Updating existing issue #$EXISTING" | |
| gh issue comment "$EXISTING" --body "$BODY" | |
| else | |
| echo "Creating new issue" | |
| gh issue create \ | |
| --title "Frontmatter validation mismatch detected" \ | |
| --body "$BODY" \ | |
| --label "frontmatter-mismatch" | |
| fi |