-
Notifications
You must be signed in to change notification settings - Fork 23
Add discussion support to add-comment safe output #1515
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
Conversation
- Update schema to include discussions in add-comment description - Add github.event.discussion.number to job condition in add_comment.go - Add discussions: write permission to add_comment job - Update add_comment.cjs to detect discussion context and use GraphQL mutation - Update TypeScript types to include discussion_number field - Update MCP server definition to include discussion support - Add test for discussion support in add_comment_discussion_test.go Co-authored-by: pelikhan <[email protected]>
- Update safe-outputs.md to include discussion context - Add discussion example workflow - Update descriptions to mention discussions alongside issues and PRs Co-authored-by: pelikhan <[email protected]>
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 update dev.md to use add-comment and trigger on a discussion comment. Write a poem to the comment.
- Add buildDisjunction function to handle multiple OR conditions elegantly - Update add_comment.go to use buildDisjunction instead of nested buildOr - Update dev.md to use add-comment safe output with discussion support - Change dev.md to write a poem about PRs as a comment Co-authored-by: pelikhan <[email protected]>
Updated
The workflow now demonstrates the new discussion comment support! Commit: 6e447b5 |
| @@ -1,24 +1,21 @@ | |||
| --- | |||
| on: | |||
| workflow_dispatch: | |||
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 add discussion created and discussion comment created events.
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.
Done! Added discussion and discussion_comment events to the schema with their respective event types:
discussion: created, edited, deleted, transferred, pinned, unpinned, labeled, unlabeled, locked, unlocked, category_changed, answered, unanswered
discussion_comment: created, edited, deleted
Updated dev.md to trigger on both discussion and discussion_comment created events. The workflow now demonstrates commenting on discussions when they are created or when comments are added.
Commit: a0e2d76
- Merged buildOr and buildDisjunction into single variadic buildOr function - Added comprehensive tests for variadic buildOr function - Added discussion and discussion_comment events to schema - Updated dev.md to trigger on discussion and discussion_comment created events - All tests pass successfully Co-authored-by: pelikhan <[email protected]>
- Updated buildOr to return DisjunctionNode for 3+ conditions instead of nested OrNode structures - DisjunctionNode renders as flat OR chain (a || b || c) avoiding deep nesting - Updated test expectations to match new flat rendering - All tests pass successfully Co-authored-by: pelikhan <[email protected]>
|
@copilot update dev.md to support workflow dispatch with a discussion number id. The input is used in the prompt to tell the agent where to add the comment |
- Added workflow_dispatch trigger with discussion_number input - Added target: "*" to add-comment to allow specifying discussion number - Updated prompt to use github.event.inputs.discussion_number or github.event.discussion.number - Added github.event.discussion.number to allowed expressions in constants - Workflow now supports manual dispatch with custom discussion number - All tests pass successfully Co-authored-by: pelikhan <[email protected]>
Done! Updated Changes:
Usage: Commit: 8f2a4b9 |
|
Done |
Add Discussion Support for add-comment Safe Output ✅
Summary
Successfully implemented comprehensive support for GitHub Discussions in the
add-commentsafe output feature. Workflows can now create comments on discussions in addition to issues and pull requests.Completed Tasks
github.event.discussion.numberaddDiscussionCommentmutationRecent Changes (Latest Commit)
discussion_numberinput parameter${{ github.event.inputs.discussion_number || github.event.discussion.number }}to support both manual dispatch and automatic discussion eventsgithub.event.discussion.numberto allowed expressions: Updated constants to allow this expression in workflow markdowntarget: "*": Allows the workflow to comment on any discussion when using workflow_dispatchKey Changes
1. Schema (
pkg/parser/schemas/main_workflow_schema.json)discussionevent with types: created, edited, deleted, transferred, pinned, unpinned, labeled, unlabeled, locked, unlocked, category_changed, answered, unanswereddiscussion_commentevent with types: created, edited, deleted2. Go Code (
pkg/workflow/add_comment.go&pkg/workflow/expressions.go)buildOr: Now accepts variadic arguments...ConditionNodeDisjunctionNodefor 3+ conditions to avoid deep nesting and improve readabilitybuildOrto check for issue, PR, or discussion eventsdiscussions: writepermission to add_comment job3. Constants (
pkg/constants/constants.go)github.event.discussion.numbertoAllowedExpressionslist for expression safety validation4. JavaScript (
pkg/workflow/js/add_comment.cjs)isDiscussionContextdetection fordiscussion/discussion_commenteventsaddDiscussionCommentmutation for creating discussion commentsissue_numberanddiscussion_numberfields in comment items5. Type Definitions (
pkg/workflow/js/types/safe-outputs.d.ts)discussion_numberfield toAddCommentIteminterface6. MCP Server (
pkg/workflow/js/safe_outputs_mcp_server.cjs)7. Tests
pkg/workflow/add_comment_discussion_test.goverifying all discussion support componentsTestBuildOrinexpressions_test.gowith comprehensive test cases for the variadic function8. Documentation (
docs/src/content/docs/reference/safe-outputs.md)discussions: writepermission requirement9. Example (
dev.md)add-commentinstead ofcreate-issuediscussionanddiscussion_commentevents as triggersworkflow_dispatchwithdiscussion_numberinput parametertarget: "*"to support manual discussion number specificationTechnical Implementation
Improved buildOr Function
workflow_dispatch Configuration (dev.md)
Dynamic Prompt
Write a delightful poem about the last 3 pull requests and add it as a comment to discussion #${{ github.event.inputs.discussion_number || github.event.discussion.number }}.Benefits of DisjunctionNode
a || b || cinstead of(a) || ((b) || (c))DisjunctionNodetypeEvent Detection
The workflow detects three context types:
issues,issue_commentpull_request,pull_request_review,pull_request_review_commentdiscussion,discussion_commentAPI Strategy
github.rest.issues.createComment)addDiscussionCommentmutation)Generated Condition (Improved)
Permissions
Testing Results
✅ All unit tests pass (6.7s)
✅ Build successful
✅ Code formatted
✅ Variadic buildOr with DisjunctionNode tested with 7 test cases
✅ dev.md compiles successfully with workflow_dispatch and discussion events
✅ Discussion and discussion_comment events validated in schema
✅ Expression safety validation includes github.event.discussion.number
Usage Examples
Discussion Workflow with Manual Dispatch (from dev.md)
Multi-Target Support
Agent can specify:
issue_number: 42for issue commentsdiscussion_number: 42for discussion commentsBackward Compatibility
✅ 100% backward compatible
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.