Skip to content

Mark Discussion Comment Answer GitHub Action πŸ™‹πŸ»β€β™‚οΈπŸ’¬βœ… Automatically mark discussion comment answers based on the highest number of positive reactions.

License

Notifications You must be signed in to change notification settings

konjoinfinity/mark-discussion-comment-answer

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

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Mark Discussion Comment Answer πŸ™‹πŸ»β€β™‚οΈπŸ’¬βœ…

This GitHub Action marks a discussion comment as the answer

Tests GitHub Workflow Status (with event) GitHub Release Date - Published_At coverage badge GitHub Marketplace GitHub package.json dynamic Dynamic YAML Badge Code Style: prettier Code Linter: ESLint GitHub top language GitHub contributors GitHub Discussions GitHub Release (with filter) GitHub code size in bytes GitHub repo size GitHub package.json dynamic MIT

About

This GitHub action automatically marks discussion comments with the highest number of reactions as the answer.

Usage

In your workflow, to use this github action add a step like this to your workflow:

      - name: Run Mark Discussion Comment Answer
        id: markanswer
        uses: konjoinfinity/[email protected]
        with:
          GH_TOKEN: "${{ secrets.DISCUSS_TOKEN }}" # PAT required for private repos
          reaction_threshold: 3 # Number of reactions required to mark a comment as the answer   
          
Example Output
DC_kwDOKczwv84AbnqH
{
  markDiscussionCommentAsAnswer: {
    clientMutationId: '1234',
    discussion: { id: 'D_kwDOKczwv84AV0aF' }
  }
}
discussionId = {id:D_kwDOKczwv84AV0aF}

Requirements

No extra configuration required to run this GitHub Action.

Inputs

Name Type Description Requried? Default
GH_TOKEN String A GitHub PAT is required, but the default is sufficient for public repos. For private repos, ensure you create a PAT that has discussion: write and repo: write, then store it as an action secret for usage within the workflow. See more details about tokens here - PAT. No "${{ secrets.GITHUB_TOKEN }}"
reaction_threshold Number Number of positive comment reactions required to mark as an answer. (Ex. 3, 10) Positive emoji reactions are: ["+1", "LAUGH", "HEART", "HOORAY", "ROCKET"] No 0

Outputs

Name Description How To Access
discussionId Discussion ID where the marked as answered comment resides. ${{ steps.<your-step>.outputs.discussionId }}
clientMutationId GraphQL Mutation ID for the client. ${{ steps.<your-step>.outputs.clientMutationId }}
commentText Body of the comment with the highest number of positive reactions/emojis. ${{ steps.<your-step>.outputs.commentText }}
reactionThreshold Number of positive reactions/emojis required to mark a comment as the answer. ${{ steps.<your-step>.outputs.reactionThreshold }}
totalReactions Total number of reactions for the comment with the highest number of positive reactions/emojis. ${{ steps.<your-step>.outputs.totalReactions }}
commentId Comment ID for the comment with the highest number of positive reactions/emojis. ${{ steps.<your-step>.outputs.commentId }}

Accessing Outputs

- name: Show Output
  run: |
    echo ${{ steps.<your-step>.outputs.discussionId }}
    echo ${{ steps.<your-step>.outputs.clientMutationId }}
    echo ${{ steps.<your-step>.outputs.commentText }}
    echo ${{ steps.<your-step>.outputs.reactionThreshold }}
    echo ${{ steps.<your-step>.outputs.totalReactions }}
    echo ${{ steps.<your-step>.outputs.commentId }}

Example

Link to workflow

name: Mark Discussion Comment Answer

on:
  discussion_comment:
    types: [created]

jobs:
  mark-comment-answer:
    name: Mark a discussion comment as the answer
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v3
        
      - name: Run Mark Discussion Comment Answer
        id: markanswer
        uses: konjoinfinity/[email protected]
        with:
          GH_TOKEN: "${{ secrets.DISCUSS_TOKEN }}" # PAT required for private repos
          reaction_threshold: 3 # Number of reactions required to mark a comment as the answer
          
      - name: Show Mark Answer Output
        run: |
          echo "discussionId = ${{ steps.markanswer.outputs.discussionId }}"
          echo "clientMutationId = ${{ steps.markanswer.outputs.clientMutationId }}"
          echo "commentText = ${{ steps.markanswer.outputs.commentText }}"
          echo "reactionThreshold = ${{ steps.markanswer.outputs.reactionThreshold }}"
          echo "totalReactions = ${{ steps.markanswer.outputs.totalReactions }}"
          echo "commentId = ${{ steps.markanswer.outputs.commentId }}"
Example Output
{
  markDiscussionCommentAsAnswer: {
    clientMutationId: '1234',
    discussion: { id: 'D_kwDOKczwv84AV0aF' }
  }
}

Credits

Inspired by:

About

Mark Discussion Comment Answer GitHub Action πŸ™‹πŸ»β€β™‚οΈπŸ’¬βœ… Automatically mark discussion comment answers based on the highest number of positive reactions.

Resources

License

Stars

Watchers

Forks

Packages

No packages published