Skip to content

wesleyscholl/discussion-auto-responder

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

98 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Discussion Autoresponder πŸ’¬β³πŸ“

Autorespond to New Discussions with a Preset Comment or Welcome Message

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

Discussion Autoresponder allows you to automatically create comments on new GitHub Discussions with a GitHub Action. This could be used to post a welcome comment, a message for responding back to new discussion topics, and other use cases.

Usage

In your workflow, to create a new discussion autoresponder for new discussion topics, include a step like this:

- name: Run discussion-auto-responder
  uses: wesleyscholl/discussion-auto-responder@v1.0.8
  id: autoresponder-comment
  with:
   GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" # Optional, if you wish you can use: "${{ secrets.<YOUR_PAT_TOKEN> }}"  
   comment_body: "This comment was generated by the Discussion Autoresponder GitHub Action." # Also optional, this is the default message.
   delay_milliseconds: 5000 # Optional to delay a comment after newly posted discussion. Written in milliseconds (ms), default 5000 ms = 5 seconds.        
       

To function as intended, ensure you have the following in your workflow:

on: 
  discussion: 
    types: [created] 

Requirements

To run this action, the Action Workflow permissions require read and write permissions in the repository for all scopes.

To configure this, go to:

  • Repository Settings

  • Actions

  • Generally

  • Workflow Permissions

  • Then select: "Read and write permissions - Workflows have read and write permissions in the repository for all scopes."

  • Finally click the save button.

Config Screenshot


Screenshot 2023-09-19 at 4 37 29 PM

Action Inputs

Name Description Requried? Default
GITHUB_TOKEN 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 }}
comment_body The contents of the autoresponder comment in string format. No "This comment was generated by the Discussion Autoresponder GitHub Action."
delay_milliseconds Amount of delay time before the autoresponder comment is posted. Written in milliseconds (ms). No 5000

Action Outputs

Name Description How To Access
discussionId The node id of the discussion where the autoresponder comment was posted. ${{ steps.<your-step>.outputs.discussionId }}
commentId The comment id posted in the discussion. ${{ steps.<your-step>.outputs.commentId }}
commentBody The body of the comment posted. ${{ steps.<your-step>.outputs.commentBody }}
clientMutationId The unique GraphQL client id. ${{ steps.<your-step>.outputs.clientMutationId }}

Example Usage To Access Outputs

- name: Show Output
  run: |
    echo "discussionId = ${{ steps.autorespond.outputs.discussionId }}"
    echo "commentId = ${{ steps.autorespond.outputs.commentId }}"
    echo "commentBody = ${{ steps.autorespond.outputs.commentBody }}"
    echo "clientMutationId = ${{ steps.autorespond.outputs.clientMutationId }}"

Example

Example workflow can be found here.

Credits

Inspired by: