Skip to content

Commit 9b90dbd

Browse files
committed
updated docusaurus agent
1 parent 5fc121c commit 9b90dbd

File tree

1 file changed

+43
-49
lines changed

1 file changed

+43
-49
lines changed

.github/workflows/agent-docusarus-dev.yml

Lines changed: 43 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -108,55 +108,49 @@ EOF
108108
max_turns: "20"
109109
model: "claude-sonnet-4-20250514"
110110

111-
- name: Post review summary
111+
- name: Post review summary (bash)
112112
if: steps.claude-review.conclusion == 'success'
113-
uses: actions/github-script@v7
114113
env:
115114
EXECUTION_FILE: ${{ steps.claude-review.outputs.execution_file }}
116-
with:
117-
github-token: ${{ secrets.NETWRIX_PROMPT_REPO_TOKEN }}
118-
script: |
119-
const fs = require('fs');
120-
const executionFile = process.env.EXECUTION_FILE;
121-
122-
if (!fs.existsSync(executionFile)) {
123-
console.log('No execution file found');
124-
return;
125-
}
126-
127-
try {
128-
const executionLog = JSON.parse(fs.readFileSync(executionFile, 'utf8'));
129-
130-
let reviewContent = '';
131-
for (let i = executionLog.length - 1; i >= 0; i--) {
132-
if (executionLog[i].role === 'assistant' && executionLog[i].content) {
133-
reviewContent = executionLog[i].content;
134-
break;
135-
}
136-
}
137-
138-
// Create comment body without using template literals or concatenation
139-
const commentParts = [
140-
'## 🤖 Claude Docusaurus Review',
141-
'',
142-
reviewContent,
143-
'',
144-
'---',
145-
'',
146-
'<sub>Automated review by Claude Code</sub>'
147-
];
148-
149-
const summary = commentParts.join('\n');
150-
151-
await github.rest.issues.createComment({
152-
issue_number: context.issue.number,
153-
owner: context.repo.owner,
154-
repo: context.repo.repo,
155-
body: summary
156-
});
157-
158-
console.log('Review posted successfully');
159-
} catch (error) {
160-
console.error('Error processing review:', error);
161-
core.setFailed(error.message);
162-
}
115+
GH_TOKEN: ${{ secrets.NETWRIX_PROMPT_REPO_TOKEN }}
116+
PR_NUMBER: ${{ github.event.pull_request.number }}
117+
run: |
118+
if [ ! -f "$EXECUTION_FILE" ]; then
119+
echo "No execution file found"
120+
exit 0
121+
fi
122+
123+
# Extract the last assistant message using jq
124+
REVIEW_CONTENT=$(jq -r '.[] | select(.role == "assistant") | .content' "$EXECUTION_FILE" | tail -1)
125+
126+
if [ -z "$REVIEW_CONTENT" ]; then
127+
echo "No review content found"
128+
exit 0
129+
fi
130+
131+
# Create comment file with proper escaping
132+
cat > /tmp/comment.md << 'HEADER'
133+
## 🤖 Claude Docusaurus Review
134+
135+
HEADER
136+
137+
# Append the review content
138+
echo "$REVIEW_CONTENT" >> /tmp/comment.md
139+
140+
# Add footer
141+
cat >> /tmp/comment.md << 'FOOTER'
142+
143+
---
144+
145+
<sub>Automated review by Claude Code</sub>
146+
FOOTER
147+
148+
# Post comment using GitHub API
149+
jq -n --arg body "$(cat /tmp/comment.md)" '{body: $body}' | \
150+
curl -X POST \
151+
-H "Authorization: token $GH_TOKEN" \
152+
-H "Accept: application/vnd.github.v3+json" \
153+
"https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \
154+
-d @-
155+
156+
echo "Review posted successfully"

0 commit comments

Comments
 (0)