test: dogfood codegraph-pr action #1
Workflow file for this run
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
| # CodeGraph PR Review — posts a code-graph analysis comment on every PR. | |
| # | |
| # Runs graph-only (no embeddings, no ONNX model) so it's fast and light: | |
| # typically completes in well under a minute even on large repos. | |
| # | |
| # Copy this file into your own repo at .github/workflows/codegraph-pr.yml | |
| # No secrets or API keys required — uses the built-in GITHUB_TOKEN. | |
| name: CodeGraph PR Review | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| review: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout (full history) | |
| uses: actions/checkout@v4 | |
| with: | |
| # fetch-depth: 0 is REQUIRED — pr_context runs | |
| # `git diff <base>...HEAD`, which needs the base branch history. | |
| # The default shallow clone breaks the diff. | |
| fetch-depth: 0 | |
| - name: Install CodeGraph | |
| run: npm install -g @astudioplus/codegraph-mcp | |
| - name: Run PR review | |
| id: review | |
| run: | | |
| # Resolve the npm-installed binary for this platform | |
| BIN="$(npm root -g)/@astudioplus/codegraph-mcp/bin/codegraph-server-linux-x64" | |
| chmod +x "$BIN" | |
| "$BIN" \ | |
| --graph-only \ | |
| --run-tool codegraph_pr_context \ | |
| --tool-args "{\"baseBranch\":\"${{ github.base_ref }}\",\"format\":\"markdown\"}" \ | |
| > review.md 2>/dev/null || echo "CodeGraph review failed" > review.md | |
| - name: Post or update PR comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const body = fs.readFileSync('review.md', 'utf8'); | |
| const marker = '## 🔍 CodeGraph PR Review'; | |
| // Find an existing CodeGraph comment to update (avoids comment spam) | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const existing = comments.find(c => c.body.startsWith(marker)); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body, | |
| }); | |
| } |