Skip to content

Commit 05e1e5f

Browse files
authored
Merge pull request #441 from netwrix/dev
rewrite doc-pr to post comments directly via gh
2 parents 0b21f68 + 03f87e4 commit 05e1e5f

2 files changed

Lines changed: 35 additions & 50 deletions

File tree

.claude/skills/doc-pr/SKILL.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Only report issues on lines that were added or modified in this PR. Do not flag
6464

6565
## Output
6666

67-
Write the complete review to `.doc-pr-review.md` in the repository root using this exact structure:
67+
After completing all three stages, post the review as a PR comment using `gh pr comment`. Build the comment body following this structure:
6868

6969
```markdown
7070
## Documentation PR Review
@@ -102,9 +102,34 @@ Write the complete review to `.doc-pr-review.md` in the repository root using th
102102
### Summary
103103

104104
N Vale issues, N Dale issues, N editorial suggestions across N files.
105+
106+
---
107+
108+
**What to do next:**
109+
110+
Comment `@claude` on this PR followed by your instructions to get help:
111+
112+
- `@claude fix all issues` — fix all Vale, Dale, and editorial issues
113+
- `@claude fix only the Vale issues` — fix just the linting problems
114+
- `@claude help improve the flow of this document` — get writing assistance
115+
- `@claude explain the voice issues` — understand why something was flagged
116+
117+
You can ask Claude anything about the review or about Netwrix writing standards.
118+
119+
> Automated fixes are only available for branches in this repository, not forks.
105120
```
106121

107-
After writing the review file, do NOT post a PR comment yourself. The workflow handles that.
122+
Post the comment with:
123+
124+
```bash
125+
gh pr comment $PR_NUMBER --repo $REPO --body "$REVIEW_BODY"
126+
```
127+
128+
Use a heredoc or temporary file to avoid shell escaping issues with the multi-line body. For example:
129+
130+
```bash
131+
gh pr comment $PR_NUMBER --repo $REPO --body-file /tmp/doc-pr-review.md
132+
```
108133

109134
## Behavioral Notes
110135

.github/workflows/claude-doc-pr.yml

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ on:
1414
types: [created]
1515

1616
jobs:
17-
# ──────────────────────────────────────────────
18-
# Job 1: Automated review on PR open or new push
19-
# ──────────────────────────────────────────────
2017
doc-review:
2118
if: github.event_name == 'pull_request'
2219
runs-on: ubuntu-latest
@@ -59,7 +56,6 @@ jobs:
5956
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6057
run: |
6158
PR_NUMBER=${{ github.event.pull_request.number }}
62-
# Find and delete previous doc-pr review comments from the bot
6359
COMMENT_IDS=$(gh api repos/${{ github.repository }}/issues/${PR_NUMBER}/comments \
6460
--jq '[.[] | select(.user.login == "github-actions[bot]" and (.body | contains("Documentation PR Review"))) | .id] | .[]' 2>/dev/null || true)
6561
for ID in $COMMENT_IDS; do
@@ -79,48 +75,16 @@ jobs:
7975
with:
8076
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
8177
github_token: ${{ secrets.GITHUB_TOKEN }}
82-
show_full_output: true
8378
prompt: |
84-
Run the doc-pr review skill on this pull request.
85-
79+
Call the doc-pr review skill:
8680
/doc-pr ${{ steps.changed-files.outputs.files }} ${{ github.event.pull_request.number }}
87-
claude_args: |
88-
--model claude-sonnet-4-5-20250929
89-
--allowedTools "Read,Write,Glob,Grep,Bash(vale:*),Bash(gh pr view:*),Bash(gh pr diff:*),Skill(doc-pr),Skill(dale)"
90-
91-
- name: Post review comment
92-
if: steps.changed-files.outputs.count > 0
93-
env:
94-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95-
PR_NUMBER: ${{ github.event.pull_request.number }}
96-
REPO: ${{ github.repository }}
97-
run: |
98-
REVIEW_FILE=".doc-pr-review.md"
99-
FOOTER=$'\n\n---\n\n'
100-
FOOTER+=$'**What to do next:**\n\n'
101-
FOOTER+=$'Comment `@claude` on this PR followed by your instructions to get help:\n\n'
102-
FOOTER+=$'- `@claude fix all issues` — fix all Vale, Dale, and editorial issues\n'
103-
FOOTER+=$'- `@claude fix only the Vale issues` — fix just the linting problems\n'
104-
FOOTER+=$'- `@claude help improve the flow of this document` — get writing assistance\n'
105-
FOOTER+=$'- `@claude explain the voice issues` — understand why something was flagged\n\n'
106-
FOOTER+=$'You can ask Claude anything about the review or about Netwrix writing standards.\n\n'
107-
FOOTER+=$'> Automated fixes are only available for branches in this repository, not forks.'
108-
109-
if [ -f "$REVIEW_FILE" ]; then
110-
BODY=$(cat "$REVIEW_FILE")
111-
else
112-
BODY="## Documentation PR Review"$'\n\n'"No review was generated. Check the workflow logs for details."
113-
fi
114-
115-
# Append footer
116-
FULL_BODY="${BODY}${FOOTER}"
11781
118-
# Post as PR comment
119-
gh pr comment "$PR_NUMBER" --repo "$REPO" --body "$FULL_BODY"
82+
Context:
83+
- REPO: ${{ github.repository }}
84+
- PR_NUMBER: ${{ github.event.pull_request.number }}
85+
- CHANGED_FILES: ${{ steps.changed-files.outputs.files }}
86+
claude_args: '--allowedTools "Bash(vale:*),Bash(gh:*),Read,Glob,Grep,Skill(doc-pr),Skill(dale)"'
12087

121-
# ──────────────────────────────────────────────
122-
# Job 2: @claude follow-up on PR comments
123-
# ──────────────────────────────────────────────
12488
doc-followup:
12589
if: >-
12690
github.event_name == 'issue_comment' &&
@@ -144,9 +108,8 @@ jobs:
144108
BASE_BRANCH=$(echo "$PR_DATA" | jq -r '.baseRefName')
145109
echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
146110
echo "branch=$(echo "$PR_DATA" | jq -r '.headRefName')" >> "$GITHUB_OUTPUT"
147-
echo "base_branch=$BASE_BRANCH" >> "$GITHUB_OUTPUT"
148111
echo "is_fork=$(echo "$PR_DATA" | jq -r '.isCrossRepository')" >> "$GITHUB_OUTPUT"
149-
# Check target branch here using the shell variable to avoid
112+
# Check target branch using the shell variable to avoid
150113
# re-interpolating the output via expressions (code injection risk).
151114
if [ "$BASE_BRANCH" = "dev" ]; then
152115
echo "targets_dev=true" >> "$GITHUB_OUTPUT"
@@ -184,9 +147,6 @@ jobs:
184147
with:
185148
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
186149
github_token: ${{ secrets.GITHUB_TOKEN }}
187-
show_full_output: true
188150
prompt: |
189151
/doc-pr-fix ${{ steps.pr-info.outputs.number }} $COMMENT_BODY
190-
claude_args: |
191-
--model claude-sonnet-4-5-20250929
192-
--allowedTools "Read,Write,Edit,Glob,Grep,Bash(vale:*),Bash(gh api:*),Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh pr comment:*),Bash(git config:*),Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git status:*),Bash(git diff:*),Skill(doc-pr-fix),Skill(dale)"
152+
claude_args: '--allowedTools "Bash(vale:*),Bash(gh:*),Bash(git:*),Read,Write,Edit,Glob,Grep,Skill(doc-pr-fix),Skill(dale)"'

0 commit comments

Comments
 (0)