GitHub Action
Mark Discussion Comment Answer ✅
v1.0.10
Latest version
This GitHub Action marks a discussion comment as the answer
This GitHub action automatically marks discussion comments with the highest number of reactions as the answer.
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
DC_kwDOKczwv84AbnqH
{
markDiscussionCommentAsAnswer: {
clientMutationId: '1234',
discussion: { id: 'D_kwDOKczwv84AV0aF' }
}
}
discussionId = {id:D_kwDOKczwv84AV0aF}
No extra configuration required to run this GitHub Action.
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 |
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 }} |
- 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 }}
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 }}"
{
markDiscussionCommentAsAnswer: {
clientMutationId: '1234',
discussion: { id: 'D_kwDOKczwv84AV0aF' }
}
}