Skip to content

Commit 5dff614

Browse files
committed
feat(workflows): add comment posting for @agentready-dev agent
- Add step to post results back to issue/PR after Claude Code Action completes - Ensure comments are attributed to @agentready-dev agent - Update Claude Code Action comments to include @agentready-dev attribution - Post status comment if Claude Code Action doesn't post automatically
1 parent 99f038d commit 5dff614

1 file changed

Lines changed: 88 additions & 1 deletion

File tree

.github/workflows/agentready-dev.yml

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,96 @@ jobs:
186186
fetch-depth: 0
187187

188188
- name: Claude Code Action
189+
id: claude-code
189190
uses: anthropics/claude-code-action@v1
191+
continue-on-error: true
190192
with:
191193
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
192194
github_token: ${{ secrets.GITHUB_TOKEN }}
193195
prompt: |
194-
@agentready-dev ${{ steps.extract-request.outputs.request }}
196+
You are responding as the @agentready-dev agent. Please analyze the request and post your response as a comment on this issue/PR.
197+
198+
Request: ${{ steps.extract-request.outputs.request }}
199+
200+
Important: Make sure to post your response as a comment and clearly indicate you are responding as the @agentready-dev agent.
201+
202+
- name: Post @agentready-dev response
203+
if: always()
204+
uses: actions/github-script@v8
205+
env:
206+
ISSUE_NUMBER: ${{ steps.event-context.outputs.issue_number }}
207+
with:
208+
script: |
209+
const issueNumber = process.env.ISSUE_NUMBER;
210+
211+
// Get the issue/PR number from context
212+
let targetNumber = issueNumber;
213+
if (!targetNumber) {
214+
// Fallback to context
215+
if (context.payload.issue) {
216+
targetNumber = context.payload.issue.number;
217+
} else if (context.payload.pull_request) {
218+
targetNumber = context.payload.pull_request.number;
219+
} else if (context.issue) {
220+
targetNumber = context.issue.number;
221+
}
222+
}
223+
224+
if (!targetNumber) {
225+
console.log('Could not determine issue/PR number');
226+
return;
227+
}
228+
229+
// Wait a moment for Claude Code Action to post its comment
230+
await new Promise(resolve => setTimeout(resolve, 3000));
231+
232+
// Get recent comments
233+
const comments = await github.rest.issues.listComments({
234+
owner: context.repo.owner,
235+
repo: context.repo.repo,
236+
issue_number: targetNumber,
237+
});
238+
239+
// Find the most recent comment from github-actions[bot] (Claude Code Action)
240+
const recentComments = comments.data
241+
.filter(comment => {
242+
const commentTime = new Date(comment.created_at);
243+
const twoMinutesAgo = new Date(Date.now() - 2 * 60 * 1000);
244+
return commentTime > twoMinutesAgo;
245+
})
246+
.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
247+
248+
const claudeComment = recentComments.find(comment =>
249+
comment.user.login === 'github-actions[bot]' &&
250+
!comment.body.includes('@agentready-dev')
251+
);
252+
253+
if (claudeComment) {
254+
// Update Claude's comment to add @agentready-dev attribution
255+
const updatedBody = `🤖 **Response from @agentready-dev agent:**\n\n---\n\n${claudeComment.body}\n\n---\n*This response was generated by the @agentready-dev workflow.*`;
256+
257+
await github.rest.issues.updateComment({
258+
owner: context.repo.owner,
259+
repo: context.repo.repo,
260+
comment_id: claudeComment.id,
261+
body: updatedBody
262+
});
263+
} else {
264+
// If no comment from Claude, post our own status comment
265+
const jobStatus = '${{ job.status }}' === 'success' ? '✅' : '❌';
266+
const statusText = '${{ job.status }}' === 'success' ? 'completed' : 'failed';
267+
268+
const body = `🤖 **@agentready-dev Agent**\n\n` +
269+
`${jobStatus} Analysis ${statusText}.\n\n` +
270+
`The @agentready-dev agent has processed your request. ` +
271+
`Please check the [workflow logs](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}) for details.\n\n` +
272+
`---\n` +
273+
`*This comment was automatically posted by the @agentready-dev workflow.*`;
274+
275+
await github.rest.issues.createComment({
276+
owner: context.repo.owner,
277+
repo: context.repo.repo,
278+
issue_number: targetNumber,
279+
body: body
280+
});
281+
}

0 commit comments

Comments
 (0)