Check MCP Server Sync #171
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: Check MCP Server Sync | |
| on: | |
| # Run on merges to main branch with documentation changes | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'docs/branding/**/*.md' | |
| - 'docs/components/**/*.md' | |
| - 'docs/layouts/**/*.md' | |
| - 'docs/patterns/**/*.md' | |
| - 'docs/content-style-guide/**/*.md' | |
| - 'docs/accessibility/**/*.md' | |
| # Run weekly on Mondays at 9 AM UTC | |
| schedule: | |
| - cron: '0 9 * * 1' | |
| # Allow manual triggering | |
| workflow_dispatch: | |
| jobs: | |
| check-sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout design-system-docs | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' # Use Node 20 which has built-in fetch | |
| - name: Install dependencies | |
| run: | | |
| # Install node-fetch as fallback for older Node versions | |
| npm init -y | |
| npm install node-fetch@2 | |
| - name: Test sync check setup | |
| run: | | |
| cd .github/scripts | |
| node test-sync-check.js | |
| - name: Run sync check | |
| id: sync-check | |
| run: | | |
| cd .github/scripts | |
| node check-mcp-sync.js > sync-output.txt 2>&1 | |
| # Capture the output | |
| if grep -q "ISSUE_NEEDED=true" sync-output.txt; then | |
| echo "sync_needed=true" >> $GITHUB_OUTPUT | |
| echo "issue_title=$(grep 'ISSUE_TITLE=' sync-output.txt | cut -d'=' -f2-)" >> $GITHUB_OUTPUT | |
| echo "issue_body=$(grep 'ISSUE_BODY=' sync-output.txt | cut -d'=' -f2-)" >> $GITHUB_OUTPUT | |
| else | |
| echo "sync_needed=false" >> $GITHUB_OUTPUT | |
| fi | |
| # Show the output for debugging | |
| cat sync-output.txt | |
| continue-on-error: true | |
| - name: Close existing sync issues | |
| if: steps.sync-check.outputs.sync_needed == 'false' | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.MCP_REPO_TOKEN }} | |
| script: | | |
| // Close any existing open sync issues | |
| const { data: issues } = await github.rest.issues.listForRepo({ | |
| owner: 'appian-design', | |
| repo: 'aurora-mcp', | |
| state: 'open', | |
| labels: 'sync-needed' | |
| }); | |
| for (const issue of issues) { | |
| await github.rest.issues.update({ | |
| owner: 'appian-design', | |
| repo: 'aurora-mcp', | |
| issue_number: issue.number, | |
| state: 'closed' | |
| }); | |
| await github.rest.issues.createComment({ | |
| owner: 'appian-design', | |
| repo: 'aurora-mcp', | |
| issue_number: issue.number, | |
| body: '✅ Sync check passed - closing this issue as resolved.' | |
| }); | |
| } | |
| - name: Create or update sync issue | |
| if: steps.sync-check.outputs.sync_needed == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.MCP_REPO_TOKEN }} | |
| script: | | |
| const issueTitle = '${{ steps.sync-check.outputs.issue_title }}'; | |
| const issueBodyBase64 = '${{ steps.sync-check.outputs.issue_body }}'; | |
| const issueBody = Buffer.from(issueBodyBase64, 'base64').toString('utf8'); | |
| // Check if there's already an open sync issue | |
| const { data: existingIssues } = await github.rest.issues.listForRepo({ | |
| owner: 'appian-design', | |
| repo: 'aurora-mcp', | |
| state: 'open', | |
| labels: 'sync-needed' | |
| }); | |
| if (existingIssues.length > 0) { | |
| // Update the existing issue | |
| const issue = existingIssues[0]; | |
| await github.rest.issues.update({ | |
| owner: 'appian-design', | |
| repo: 'aurora-mcp', | |
| issue_number: issue.number, | |
| title: issueTitle, | |
| body: issueBody | |
| }); | |
| await github.rest.issues.createComment({ | |
| owner: 'appian-design', | |
| repo: 'aurora-mcp', | |
| issue_number: issue.number, | |
| body: '🔄 Issue updated with latest sync requirements.' | |
| }); | |
| console.log(`Updated existing issue #${issue.number}`); | |
| } else { | |
| // Create a new issue | |
| const { data: newIssue } = await github.rest.issues.create({ | |
| owner: 'appian-design', | |
| repo: 'aurora-mcp', | |
| title: issueTitle, | |
| body: issueBody, | |
| labels: ['sync-needed', 'automated'] | |
| }); | |
| console.log(`Created new issue #${newIssue.number}`); | |
| } | |
| - name: Summary | |
| run: | | |
| if [ "${{ steps.sync-check.outputs.sync_needed }}" == "true" ]; then | |
| echo "⚠️ MCP server sync required - issue created/updated" | |
| else | |
| echo "✅ MCP server is in sync" | |
| fi |