|
| 1 | +name: Address Blog Review |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_review: |
| 5 | + types: [submitted] |
| 6 | + branches: |
| 7 | + - 'blog/**' |
| 8 | + |
| 9 | +jobs: |
| 10 | + address-review: |
| 11 | + name: Address Review Comments |
| 12 | + # Only run for reviews with comments, not plain approvals |
| 13 | + if: github.event.review.state == 'commented' || github.event.review.state == 'changes_requested' |
| 14 | + runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + contents: write |
| 17 | + pull-requests: write |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout PR branch |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + ref: ${{ github.event.pull_request.head.ref }} |
| 24 | + |
| 25 | + - name: Install Claude Code |
| 26 | + run: npm install -g @anthropic-ai/claude-code |
| 27 | + |
| 28 | + - name: Address review comments |
| 29 | + env: |
| 30 | + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
| 31 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + PR_NUMBER: ${{ github.event.pull_request.number }} |
| 33 | + REPO: ${{ github.repository }} |
| 34 | + REVIEW_ID: ${{ github.event.review.id }} |
| 35 | + run: | |
| 36 | + claude --dangerously-skip-permissions -p " |
| 37 | + You are addressing review comments on a blog post PR. |
| 38 | +
|
| 39 | + Context: |
| 40 | + - Repository: $REPO |
| 41 | + - PR number: $PR_NUMBER |
| 42 | + - Review ID: $REVIEW_ID |
| 43 | +
|
| 44 | + Steps: |
| 45 | + 1. Fetch the review comments using: gh api repos/$REPO/pulls/$PR_NUMBER/comments |
| 46 | + Filter to comments from review ID $REVIEW_ID. |
| 47 | + 2. Read the blog post file that was changed in this PR (check git diff --name-only to find it). |
| 48 | + 3. Read the write-blog-post skill in .claude/skills/write-blog-post/skill.md for style guidelines. |
| 49 | + 4. For each review comment, assess whether it is valid: |
| 50 | + - Is it factually correct? |
| 51 | + - Does it improve accuracy, clarity, or tone? |
| 52 | + - Does it align with the writing style guidelines? |
| 53 | + 5. For valid comments: edit the blog post to address the feedback. |
| 54 | + 6. For invalid or subjective comments: prepare a brief explanation of why no change is needed. |
| 55 | + 7. Reply to EACH review comment using: |
| 56 | + gh api repos/$REPO/pulls/$PR_NUMBER/comments/{comment_id}/replies -f body='...' |
| 57 | + - If fixed: 'Fixed. [what was changed]' |
| 58 | + - If rejected: 'Keeping as-is. [brief reason]' |
| 59 | + 8. Do NOT fabricate facts. If a review comment asks you to add information you cannot verify, say so in the reply. |
| 60 | + " |
| 61 | +
|
| 62 | + - name: Check for changes |
| 63 | + id: check |
| 64 | + run: | |
| 65 | + if git diff --quiet; then |
| 66 | + echo "has_changes=false" >> "$GITHUB_OUTPUT" |
| 67 | + else |
| 68 | + echo "has_changes=true" >> "$GITHUB_OUTPUT" |
| 69 | + fi |
| 70 | +
|
| 71 | + - name: Commit and push changes |
| 72 | + if: steps.check.outputs.has_changes == 'true' |
| 73 | + env: |
| 74 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + run: | |
| 76 | + git config user.name "github-actions[bot]" |
| 77 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 78 | + git add website/content/blog/ |
| 79 | + git commit -m "blog: address review comments |
| 80 | +
|
| 81 | + Co-Authored-By: Claude <noreply@anthropic.com>" |
| 82 | + git push |
0 commit comments