GitHub Action
Discussion Auto Responder
Autorespond to New Discussions with a Preset Comment or Welcome Message
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.
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]
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.
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 |
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 }} |
- 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 workflow can be found here.