https://github.com/konjoinfinity/mark-discussion-comment-answer
Mark Discussion Comment Answer GitHub Action 🙋🏻♂️💬✅ Automatically mark discussion comment answers based on the highest number of positive reactions.
https://github.com/konjoinfinity/mark-discussion-comment-answer
Last synced: 9 months ago
JSON representation
Mark Discussion Comment Answer GitHub Action 🙋🏻♂️💬✅ Automatically mark discussion comment answers based on the highest number of positive reactions.
- Host: GitHub
- URL: https://github.com/konjoinfinity/mark-discussion-comment-answer
- Owner: konjoinfinity
- License: mit
- Created: 2023-10-06T10:49:43.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-15T05:37:48.000Z (over 2 years ago)
- Last Synced: 2024-11-12T17:49:00.433Z (over 1 year ago)
- Language: TypeScript
- Size: 4.1 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mark Discussion Comment Answer 🙋🏻♂️💬✅
This GitHub Action marks a discussion comment as the answer
[](https://github.com/konjoinfinity/mark-discussion-comment-answer/blob/main/src/__tests__/index.test.ts)   [](https://gist.github.com/wesleyscholl/10f0b77400703c4a65f38434106adf2d) [](https://github.com/marketplace/actions/mark-discussion-comment-answer)   [](https://github.com/prettier/prettier) [](https://github.com/prettier/prettier)        [](https://raw.githubusercontent.com/konjoinfinity/mark-discussion-comment-answer/main/LICENSE)
## 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:
```yaml
- name: Run Mark Discussion Comment Answer
id: markanswer
uses: konjoinfinity/mark-discussion-comment-answer@v1.0.x
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
```bash
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](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). | **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..outputs.discussionId }}` |
| `clientMutationId` | GraphQL Mutation ID for the client. | `${{ steps..outputs.clientMutationId }}` |
| `commentText` | Body of the comment with the highest number of positive reactions/emojis. | `${{ steps..outputs.commentText }}` |
| `reactionThreshold` | Number of positive reactions/emojis required to mark a comment as the answer. | `${{ steps..outputs.reactionThreshold }}` |
| `totalReactions` | Total number of reactions for the comment with the highest number of positive reactions/emojis. | `${{ steps..outputs.totalReactions }}` |
| `commentId` | Comment ID for the comment with the highest number of positive reactions/emojis. | `${{ steps..outputs.commentId }}` |
#### Accessing Outputs
```yml
- name: Show Output
run: |
echo ${{ steps..outputs.discussionId }}
echo ${{ steps..outputs.clientMutationId }}
echo ${{ steps..outputs.commentText }}
echo ${{ steps..outputs.reactionThreshold }}
echo ${{ steps..outputs.totalReactions }}
echo ${{ steps..outputs.commentId }}
```
## Example
Link to [workflow](https://raw.githubusercontent.com/wesleyscholl/auto/main/.github/workflows/new.yaml)
```yaml
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/mark-discussion-comment-answer@v1.0.x
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
```js
{
markDiscussionCommentAsAnswer: {
clientMutationId: '1234',
discussion: { id: 'D_kwDOKczwv84AV0aF' }
}
}
```
## Credits
- [Using the GraphQL API for Discussions](https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions)
- [GitHub GraphQL Explorer](https://docs.github.com/en/graphql/overview/explorer)
#### Inspired by:
- [Create and Publish a GitHub Action in Typescript - Leonardo Montini](https://leonardomontini.dev/typescript-github-action/)
- [Discussion Autoresponder - GitHub Action](https://github.com/marketplace/actions/discussion-auto-responder)