π Automate your GitHub Discussions with ease! Add comments to existing GitHub Discussions seamlessly using GitHub Actions.
The Create Discussion Comment action empowers you to programmatically add comments to your GitHub Discussions using GitHub Actions workflows. Whether you're building automated workflows, creating notification systems, or enhancing your community engagement, this action makes it simple to interact with GitHub Discussions at scale.
- π€ Automated responses to discussion topics
- π’ Notifications about workflow completions
- π‘ Bot interactions in community discussions
- π Cross-referencing issues and discussions
- π Status updates on project milestones
- π Welcome messages for new community members
- π― Targeted Comments: Add comments to specific discussions using their unique ID
- π§΅ Thread Replies: Reply to existing comments to maintain conversation flow
- π Secure Authentication: Uses GitHub Personal Access Tokens for secure API access
- ποΈ Flexible Integration: Works with any GitHub Actions workflow
- π Rich Content Support: Full markdown support in comment bodies
- π Custom Mutation IDs: Track your mutations with custom identifiers
Add this step to your GitHub Actions workflow to create a comment on any discussion:
- name: π¬ Create Discussion Comment
uses: wesleyscholl/[email protected]
id: create-comment
with:
token: ${{ secrets.DISCUSS_TOKEN }}
body: |
## π Workflow Completed Successfully!
This comment was automatically generated by a GitHub Action.
**Deployment Status**: β
Success
**Timestamp**: ${{ github.event.head_commit.timestamp }}
**Commit**: ${{ github.sha }}
discussion-id: 'D_kwdje64ife75s9o'
client-mutation-id: 'workflow-${{ github.run_id }}'
- name: π Reply to Discussion Comment
uses: wesleyscholl/[email protected]
with:
token: ${{ secrets.DISCUSS_TOKEN }}
body: |
π Thanks for your question!
Based on the latest deployment, here's the status update you requested:
- β
Build completed
- β
Tests passed
- β
Deployed to production
discussion-id: 'D_kwdje64ife75s9o'
replyToId: 'DC_kwdje64ife75s9o_reply'
client-mutation-id: 'reply-${{ github.run_number }}'
Parameter | Description | Required | Default | Example |
---|---|---|---|---|
token |
π GitHub Personal Access Token with appropriate permissions | β Yes | N/A | ${{ secrets.DISCUSS_TOKEN }} |
body |
π The comment content (supports full Markdown) | β No | "Comment provided by GitHub Action create-discussion-comment" |
"Hello from GitHub Actions! π" |
discussion-id |
π― The unique node ID of the target discussion | β Yes | N/A | 'D_kwdje64ife75s9o' |
client-mutation-id |
π Unique identifier for tracking the mutation | β No | "1234" |
'workflow-${{ github.run_id }}' |
replyToId |
π§΅ Node ID of the comment to reply to (for threaded replies) | β No | N/A | 'DC_kwdje64ife75s9o' |
Output | Description | Example |
---|---|---|
clientMutationId |
π The unique identifier you provided | "workflow-123" |
comment |
π¬ The complete comment object that was created | See response example below |
{
"data": {
"addDiscussionComment": {
"clientMutationId": "workflow-123",
"comment": {
"id": "DC_kwdje64ife75s9o",
"body": "π Your automated comment content here!"
}
}
}
}
- Visit the GitHub GraphQL Explorer
- Use this query (replace
<REPO_OWNER>
and<REPO_NAME>
):
query GetDiscussions($owner: String!, $name: String!) {
repository(owner: $owner, name: $name) {
discussions(first: 10, orderBy: {field: UPDATED_AT, direction: DESC}) {
edges {
node {
id # π― This is your discussion-id!
title
number
category {
id
name
emoji
}
body
createdAt
updatedAt
author {
login
}
}
}
}
}
}
You can also find the discussion ID in the browser:
- Navigate to your discussion
- The URL will look like:
https://github.com/owner/repo/discussions/123
- Use GraphQL to convert the number to the node ID
Your Personal Access Token needs these scopes:
- β
public_repo
- For public repositories - β
repo
- For private repositories - β
write:discussion
- To create and modify discussion comments
- Store tokens securely: Always use GitHub Secrets (
${{ secrets.TOKEN_NAME }}
) - Minimal permissions: Only grant the minimum required scopes
- Token rotation: Regularly rotate your Personal Access Tokens
- Monitor usage: Keep track of where and how your tokens are used
body: |
## π Weekly Build Report
**Period**: ${{ github.event.schedule }}
### π Statistics
- β
Successful builds: 47
- β Failed builds: 3
- β±οΈ Average build time: 4m 32s
### π Top Contributors This Week
@contributor1, @contributor2, @contributor3
body: |
## π New Release: v${{ github.ref_name }}
We're excited to announce our latest release!
### β¨ What's New
- π Bug fixes and performance improvements
- π New features based on community feedback
- π Updated documentation
**Download**: [Release Notes](https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }})
body: |
## π Welcome to our community!
Thanks for starting this discussion! Here are some helpful resources:
- π [Getting Started Guide](link)
- π¬ [Community Guidelines](link)
- π [Bug Report Template](link)
Our team will respond within 24-48 hours. Happy coding! π
Check out our example workflows to see the action in various scenarios:
- π CI/CD Status Updates: Automatically comment on discussions when builds complete
- π Scheduled Reports: Weekly/monthly automated status reports
- π― Issue Crosslinking: Link related issues and discussions automatically
- π€ Bot Responses: Create intelligent bot responses based on discussion content
We welcome contributions! Here's how you can help:
- π Report bugs by opening an issue
- π‘ Suggest features through discussions
- π§ Submit pull requests with improvements
- π Improve documentation
- β Star this repository to show your support
- Fork this repository
- Clone your fork:
git clone https://github.com/YOUR-USERNAME/create-discussion-comment.git
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes and test
- Submit a pull request
This action was inspired by these amazing projects:
- π¬ peter-evans/create-or-update-comment - For comment management patterns
- π£οΈ abirismyname/create-discussion - For discussion creation workflows
Special thanks to all our contributors and the GitHub Actions community! π
This project is licensed under the MIT License - see the LICENSE file for details.
- π Bug reports: Open an issue
- π‘ Feature requests: Start a discussion
- π Documentation: GitHub Actions Documentation
- π¬ Community: GitHub Discussions
Made with β€οΈ by @wesleyscholl
β Star this repository if you found it helpful!
πͺ GitHub Marketplace β’ π Documentation β’ π Issues β’ π¬ Discussions