Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 20, 2025

This PR implements the output.comment output type that creates issue or pull request comments from agent output, following the same patterns as the existing output.issue functionality. Additionally, it enables workflows to support multiple output types simultaneously.

What's New

Users can now configure workflows to automatically post agent output as comments on issues or pull requests, and can combine multiple output types in a single workflow:

---
on:
  issues:
    types: [opened, labeled]
  pull_request:
    types: [opened, synchronize]
permissions:
  contents: read
  actions: read
engine: claude
output:
  issue:
    title-prefix: "[claude-test] "
    labels: [claude, automation, haiku]
  comment: {}
---

# Issue/PR Analysis Agent

Analyze the issue or pull request and provide feedback.
Write your analysis to ${{ env.GITHUB_AW_OUTPUT }} at the end.

Key Features

  • Smart Context Detection: Automatically detects whether the workflow is running in an issue or pull request context
  • Conditional Execution: The comment job only runs when github.event.issue.number or github.event.pull_request.number is present, gracefully skipping for other event types
  • Proper Permissions: Separate job with issues: write and pull-requests: write permissions, keeping the main job minimal
  • Full Agent Output: Posts the entire agent output as comment content without parsing (unlike issue creation which splits title/body)
  • Multiple Output Support: Workflows can now have both issue and comment outputs simultaneously, enabling rich automation workflows

Implementation Details

  • Job Name: create_issue_comment with 10-minute timeout
  • Dependencies: Runs after the main agent job completes
  • API: Uses GitHub Issues API (works for both issues and PRs)
  • Outputs: Returns comment_id and comment_url for downstream jobs
  • Schema: Updated to support the new output.comment configuration

Example Generated Workflow

The compiler generates a conditional job that:

  1. Receives agent output from the main job via job outputs
  2. Checks GitHub context to determine issue/PR number
  3. Posts comment using github.rest.issues.createComment()
  4. Skips execution if not in issue/PR context

This maintains the same separation of concerns as output.issue where the main job doesn't need write permissions, improving security and following the principle of least privilege.

The test workflow test-claude.md has been updated to demonstrate this functionality by both creating issues AND posting analysis results as PR comments, showcasing the multiple output support capability.

Fixes #129.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Add output type for posting agent output as issue or PR comment Add output.comment type for posting agent output as issue/PR comments Aug 20, 2025
Copilot finished work on behalf of pelikhan August 20, 2025 06:59
@Copilot Copilot AI requested a review from pelikhan August 20, 2025 06:59
@pelikhan pelikhan marked this pull request as ready for review August 20, 2025 07:02
@pelikhan
Copy link
Contributor

@copilot update test-claude.md to use comment: {}

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 20, 2025

@copilot update test-claude.md to use comment: {}

Updated test-claude.md to use comment: {} as requested. The workflow will now post agent output as comments on PRs instead of creating separate issues. Commit: 7fc8e8d

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.contoso.com
    • Triggering command: /tmp/go-build818669168/b278/cli.test -test.testlogfile=/tmp/go-build818669168/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@Copilot Copilot AI requested a review from pelikhan August 20, 2025 11:50
Copilot finished work on behalf of pelikhan August 20, 2025 11:50
@@ -16,9 +16,7 @@ permissions:
pull-requests: write
actions: read
output:
issue:
Copy link
Contributor

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

Copy link
Contributor Author

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

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 20, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.contoso.com
    • Triggering command: /tmp/go-build2427520505/b278/cli.test -test.testlogfile=/tmp/go-build2427520505/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@Copilot Copilot AI changed the title Add output.comment type for posting agent output as issue/PR comments Add output.comment type for posting agent output as issue/PR comments with multiple output support Aug 20, 2025
@Copilot Copilot AI requested a review from pelikhan August 20, 2025 12:01
Copilot finished work on behalf of pelikhan August 20, 2025 12:01
@pelikhan pelikhan enabled auto-merge (squash) August 20, 2025 13:21
@pelikhan pelikhan disabled auto-merge August 20, 2025 13:21
@pelikhan pelikhan merged commit 6af64ff into main Aug 20, 2025
6 checks passed
@pelikhan pelikhan deleted the copilot/fix-129 branch August 20, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[copilot] Add output type for posting agent output as issue or PR comment
2 participants