-
Notifications
You must be signed in to change notification settings - Fork 296
Add output.comment type for posting agent output as issue/PR comments with multiple output support #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add output.comment type for posting agent output as issue/PR comments with multiple output support #130
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5d963db
Initial plan
Copilot 954545a
Implement output.comment functionality for issue/PR comments
Copilot 7fc8e8d
Update test-claude.md to use output.comment instead of output.issue
Copilot fea0dd3
Add both issue and comment output options to test-claude.md
Copilot c4a990b
Merge branch 'main' into copilot/fix-129
pelikhan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Read the agent output content from environment variable | ||
| const outputContent = process.env.AGENT_OUTPUT_CONTENT; | ||
| if (!outputContent) { | ||
| console.log('No AGENT_OUTPUT_CONTENT environment variable found'); | ||
| return; | ||
| } | ||
|
|
||
| if (outputContent.trim() === '') { | ||
| console.log('Agent output content is empty'); | ||
| return; | ||
| } | ||
|
|
||
| console.log('Agent output content length:', outputContent.length); | ||
|
|
||
| // Check if we're in an issue or pull request context | ||
| const isIssueContext = context.eventName === 'issues' || context.eventName === 'issue_comment'; | ||
| const isPRContext = context.eventName === 'pull_request' || context.eventName === 'pull_request_review' || context.eventName === 'pull_request_review_comment'; | ||
|
|
||
| if (!isIssueContext && !isPRContext) { | ||
| console.log('Not running in issue or pull request context, skipping comment creation'); | ||
| return; | ||
| } | ||
|
|
||
| // Determine the issue/PR number and comment endpoint | ||
| let issueNumber; | ||
| let commentEndpoint; | ||
|
|
||
| if (isIssueContext) { | ||
| if (context.payload.issue) { | ||
| issueNumber = context.payload.issue.number; | ||
| commentEndpoint = 'issues'; | ||
| } else { | ||
| console.log('Issue context detected but no issue found in payload'); | ||
| return; | ||
| } | ||
| } else if (isPRContext) { | ||
| if (context.payload.pull_request) { | ||
| issueNumber = context.payload.pull_request.number; | ||
| commentEndpoint = 'issues'; // PR comments use the issues API endpoint | ||
| } else { | ||
| console.log('Pull request context detected but no pull request found in payload'); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| if (!issueNumber) { | ||
| console.log('Could not determine issue or pull request number'); | ||
| return; | ||
| } | ||
|
|
||
| console.log(`Creating comment on ${commentEndpoint} #${issueNumber}`); | ||
| console.log('Comment content length:', outputContent.length); | ||
|
|
||
| // Create the comment using GitHub API | ||
| const { data: comment } = await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issueNumber, | ||
| body: outputContent | ||
| }); | ||
|
|
||
| console.log('Created comment #' + comment.id + ': ' + comment.html_url); | ||
|
|
||
| // Set output for other jobs to use | ||
| core.setOutput('comment_id', comment.id); | ||
| core.setOutput('comment_url', comment.html_url); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot keep the issue section, output should support multiple options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated test-claude.md to keep both issue and comment output options as requested. The workflow now supports multiple output types simultaneously, demonstrating the full functionality. Commit: fea0dd3