Skip to content

Commit 296eed3

Browse files
authored
Merge pull request #481 from netwrix/dev
dismiss Vale review and re-run after followup fixes
2 parents d2573bd + ca964b1 commit 296eed3

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

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

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,65 @@ jobs:
268268
prompt: |
269269
/doc-pr-fix ${{ steps.pr-info.outputs.number }} $COMMENT_BODY
270270
claude_args: '--allowedTools "Bash(vale:*),Bash(gh:*),Bash(git:*),Read,Write,Edit,Glob,Grep,Skill(doc-pr-fix),Skill(dale)"'
271+
272+
- name: Re-run Vale and update inline comments
273+
if: steps.pr-info.outputs.is_fork == 'false' && steps.pr-info.outputs.targets_dev == 'true'
274+
env:
275+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
276+
run: |
277+
PR_NUMBER=${{ steps.pr-info.outputs.number }}
278+
REPO=${{ github.repository }}
279+
280+
# Dismiss all previous Vale reviews
281+
REVIEW_IDS=$(gh api repos/${REPO}/pulls/${PR_NUMBER}/reviews \
282+
--jq '[.[] | select(.user.login == "github-actions[bot]" and (.body | contains("Vale found"))) | .id] | .[]' 2>/dev/null || true)
283+
for ID in $REVIEW_IDS; do
284+
gh api repos/${REPO}/pulls/${PR_NUMBER}/reviews/${ID}/dismissals \
285+
-f message="Superseded after fixes applied" -f event="DISMISS" 2>/dev/null || true
286+
done
287+
288+
# Pull latest changes from Claude's push
289+
git pull origin ${{ steps.pr-info.outputs.branch }} 2>/dev/null || true
290+
291+
# Get changed files
292+
CHANGED_MD_FILES=$(gh pr diff "$PR_NUMBER" --name-only | grep -E '^docs/.*\.md$' | grep -v '/CLAUDE\.md$' | grep -v '/SKILL\.md$' || true)
293+
if [ -z "$CHANGED_MD_FILES" ]; then
294+
echo "No docs markdown files to re-check"
295+
exit 0
296+
fi
297+
298+
# Re-run Vale and collect results
299+
VALE_COUNT=0
300+
COMMENTS_JSON="[]"
301+
while IFS= read -r FILE; do
302+
if [ -f "$FILE" ]; then
303+
RESULT=$(vale --output=line "$FILE" 2>&1 || true)
304+
if [ -n "$RESULT" ]; then
305+
while IFS= read -r LINE; do
306+
LINE_NUM=$(echo "$LINE" | cut -d: -f2)
307+
RULE=$(echo "$LINE" | cut -d: -f4)
308+
MESSAGE=$(echo "$LINE" | cut -d: -f5-)
309+
if [ -n "$LINE_NUM" ] && [ -n "$MESSAGE" ]; then
310+
BODY="**Vale** (\`${RULE}\`): ${MESSAGE}"
311+
COMMENTS_JSON=$(echo "$COMMENTS_JSON" | jq \
312+
--arg path "$FILE" \
313+
--argjson line "$LINE_NUM" \
314+
--arg body "$BODY" \
315+
'. += [{"path": $path, "line": $line, "body": $body}]')
316+
VALE_COUNT=$((VALE_COUNT + 1))
317+
fi
318+
done <<< "$RESULT"
319+
fi
320+
fi
321+
done <<< "$CHANGED_MD_FILES"
322+
323+
if [ "$VALE_COUNT" -gt 0 ]; then
324+
echo "Vale still found $VALE_COUNT issue(s) after fixes"
325+
jq -n \
326+
--arg body "**Vale found ${VALE_COUNT} remaining issue(s) after fixes.** See inline comments below." \
327+
--argjson comments "$COMMENTS_JSON" \
328+
'{"body": $body, "event": "COMMENT", "comments": $comments}' \
329+
| gh api repos/${REPO}/pulls/${PR_NUMBER}/reviews --input - 2>&1
330+
else
331+
echo "All Vale issues resolved"
332+
fi

0 commit comments

Comments
 (0)