Skip to content

add a github action for generating mermaid diagram on 'needs-diagram' PR#2095

Open
jeesunikim wants to merge 1 commit into
mainfrom
pr-diagram-testing
Open

add a github action for generating mermaid diagram on 'needs-diagram' PR#2095
jeesunikim wants to merge 1 commit into
mainfrom
pr-diagram-testing

Conversation

@jeesunikim
Copy link
Copy Markdown
Contributor

  • enabling playground plugin for generating html for easy code review (example)
  • github action pr-diagram.yml:
    -- Triggers only on pull_request: labeled with needs-diagram
    -- Concurrency group cancels in-progress runs if you re-label quickly
    -- Fetches diff via gh pr diff, truncates to 200KB if oversized (line 32–43)
    -- Calls Anthropic API (Sonnet 4.6) via Python stdlib — no extra deps needed (line 49–93)
    -- Updates the PR body between / markers; appends if absent (line 95–134)

Copilot AI review requested due to automatic review settings May 21, 2026 18:36
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX May 21, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds automation to generate and embed a Mermaid “architecture diagram” into PR descriptions when a needs-diagram label is applied, plus enables a Claude plugin intended to make generated HTML easier to review.

Changes:

  • Introduces a new GitHub Actions workflow that fetches a PR diff, calls Anthropic to generate a Mermaid diagram, and updates the PR body between marker comments.
  • Adds .claude/settings.json to enable the playground plugin.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
.github/workflows/pr-diagram.yml New workflow to generate Mermaid diagrams from PR diffs and write them into the PR body on needs-diagram labeling.
.claude/settings.json Enables the playground@claude-plugins-official plugin.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +61 to +70
payload = {
"model": "claude-sonnet-4-6",
"max_tokens": 4096,
"system": system,
"messages": [{
"role": "user",
"content": (
"Generate a Mermaid diagram summarizing the architectural "
"changes in this PR diff:\n\n" + diff
),
Comment on lines +7 to +25
on:
pull_request:
types: [labeled]

permissions:
contents: read
pull-requests: write

concurrency:
group: pr-diagram-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
diagram:
if: github.event.label.name == 'needs-diagram'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
Comment on lines +111 to +115
# Extract the fenced mermaid block in case the model wrapped it in prose.
match = re.search(r'```mermaid.*?```', mermaid, re.DOTALL)
if match:
mermaid = match.group(0)

Comment on lines +24 to +32
- name: Checkout
uses: actions/checkout@v4

- name: Fetch PR diff
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR: ${{ github.event.pull_request.number }}
run: |
gh pr diff "$PR" > /tmp/pr.diff
@stellar-jenkins-ci
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog (Not Ready)

Development

Successfully merging this pull request may close these issues.

2 participants