Generate Patterns #213
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: Generate Patterns | |
| on: | |
| # Run on schedule (daily at 00:00 UTC) | |
| schedule: | |
| - cron: "0 0 * * *" | |
| # Allow manual trigger | |
| workflow_dispatch: | |
| # Run on push to main (when patterns source changes) | |
| push: | |
| branches: [main] | |
| paths: | |
| - "data/**" | |
| - ".github/workflows/generate-patterns.yml" | |
| jobs: | |
| generate: | |
| name: Generate patterns.json | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Generate patterns | |
| run: | | |
| # Run the full publishing pipeline to validate and prepare patterns | |
| bun run ep:admin publish pipeline | |
| - name: Verify patterns.json | |
| run: | | |
| # Check if patterns.json exists in MCP server data directory | |
| if [ ! -f "services/mcp-server/data/patterns.json" ]; then | |
| echo "Error: patterns.json not found" | |
| exit 1 | |
| fi | |
| # Validate JSON format | |
| if ! jq empty "services/mcp-server/data/patterns.json" 2>/dev/null; then | |
| echo "Error: Invalid JSON in patterns.json" | |
| exit 1 | |
| fi | |
| echo "✅ patterns.json validated successfully" | |
| - name: Upload patterns.json as artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: patterns-data | |
| path: services/mcp-server/data/patterns.json | |
| retention-days: 30 | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if git diff --quiet services/mcp-server/data/patterns.json; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit updated patterns | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add services/mcp-server/data/patterns.json | |
| git commit -m "chore: regenerate patterns from published sources | |
| Updated patterns.json based on latest published patterns. | |
| 🤖 Generated with [Claude Code](https://claude.com/claude-code)" | |
| git push |