Skip to content

πŸ’¬πŸ€– Automate GitHub Discussions with ease! A powerful GitHub Action that creates comments on existing discussions programmatically. Perfect for CI/CD workflows, community engagement & automation. πŸ””βœ…

License

Notifications You must be signed in to change notification settings

wesleyscholl/create-discussion-comment

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

95 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Create Discussion Comment βŒ¨οΈπŸ’¬βœ…

πŸš€ Automate your GitHub Discussions with ease! Add comments to existing GitHub Discussions seamlessly using GitHub Actions.

Tests Code Style: prettier GitHub Marketplace

🌟 What is this Action?

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.

🎯 Perfect for:

  • πŸ€– 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

✨ Key Features

  • 🎯 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

πŸš€ Quick Start

Basic Usage

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 }}'

Advanced Example: Replying to Comments

- 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 }}'

πŸ“‹ Configuration Options

πŸ”§ Input Parameters

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 Data

Output Description Example
clientMutationId πŸ†” The unique identifier you provided "workflow-123"
comment πŸ’¬ The complete comment object that was created See response example below

πŸ“Š Response Format

{
  "data": {
    "addDiscussionComment": {
      "clientMutationId": "workflow-123",
      "comment": {
        "id": "DC_kwdje64ife75s9o",
        "body": "πŸŽ‰ Your automated comment content here!"
      }
    }
  }
}

πŸ” Finding Your Discussion ID

Method 1: GitHub GraphQL Explorer πŸ”¬

  1. Visit the GitHub GraphQL Explorer
  2. 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
          }
        }
      }
    }
  }
}

Method 2: Discussion URL Pattern πŸ”—

You can also find the discussion ID in the browser:

  1. Navigate to your discussion
  2. The URL will look like: https://github.com/owner/repo/discussions/123
  3. Use GraphQL to convert the number to the node ID

πŸ›‘οΈ Security & Permissions

Required Token Permissions πŸ”

Your Personal Access Token needs these scopes:

  • βœ… public_repo - For public repositories
  • βœ… repo - For private repositories
  • βœ… write:discussion - To create and modify discussion comments

πŸ”’ Security Best Practices

  1. Store tokens securely: Always use GitHub Secrets (${{ secrets.TOKEN_NAME }})
  2. Minimal permissions: Only grant the minimum required scopes
  3. Token rotation: Regularly rotate your Personal Access Tokens
  4. Monitor usage: Keep track of where and how your tokens are used

🎨 Creative Use Cases

πŸ“Š Automated Status Reports

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

πŸŽ‰ Release Announcements

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 }})

πŸ€– Community Engagement

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! πŸŽ‰

πŸ§ͺ Example Workflows

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

🀝 Contributing

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

πŸš€ Development Setup

  1. Fork this repository
  2. Clone your fork: git clone https://github.com/YOUR-USERNAME/create-discussion-comment.git
  3. Create a feature branch: git checkout -b feature/amazing-feature
  4. Make your changes and test
  5. Submit a pull request

πŸ™ Acknowledgments & Credits

This action was inspired by these amazing projects:

Special thanks to all our contributors and the GitHub Actions community! πŸŽ‰

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“ž Support & Community


Made with ❀️ by @wesleyscholl

⭐ Star this repository if you found it helpful!

πŸͺ GitHub Marketplace β€’ πŸ“š Documentation β€’ πŸ› Issues β€’ πŸ’¬ Discussions

About

πŸ’¬πŸ€– Automate GitHub Discussions with ease! A powerful GitHub Action that creates comments on existing discussions programmatically. Perfect for CI/CD workflows, community engagement & automation. πŸ””βœ…

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published