This action allows you to add comments to GitHub Discussions using GitHub Actions.
In your workflow, to create a new comment on a discussion topic, include a step like this:
- name: Run create-discussion-comment
uses: wesleyscholl/[email protected]
id: create-comment
with:
token: ${{ secrets.DISCUSS_TOKEN }}
body: "This is a test comment from a GitHub action"
discussion-id: 'D_kwdje64ife75s9o'
client-mutation-id: '1234'
Ensure you provide the discussion ID, this can be found using the GitHub GraphQL Explorer. (See below)
Name | Description | Requried? | Default |
---|---|---|---|
token |
A GitHub PAT is required. Ensure the PAT has discussion: write and public_repo: read for public repos and repo: write for private repositories. See more details about tokens here PAT. |
Yes | N/A |
body |
The contents of the comment in string format. | No | "Comment provided by GitHub Action create-discussion-comment" |
discussion-id |
The node ID of the discussion to comment on. This can be found using the GitHub GraphQL explorer, more details below. | Yes | N/A |
client-mutation-id |
A unique identifier for the client performing the mutation. | No | "1234" |
replyToId |
The node ID of the discussion comment to reply to. If absent, the created comment will be a top-level comment. | No | N/A |
Name | Description | Data Model |
---|---|---|
clientMutationId |
The unique identifier provided as an input. | See below |
comment |
The discussion comment that was created. | See below |
{"data":
{"addDiscussionComment":
{"clientMutationId":"1234",
"comment":{
"id":"DC_kwdje64ife75s9o",
"body":"This is a test comment from a GitHub action"
}}}}
You can find your discussion-id
and using GitHub's GraphQL Explorer. Replace <REPO_NAME>
and <REPO_OWNER>
to find the discussion id you wish to comment on.
query {
repository(owner: "<REPO_OWNER>`", name: "cohere") {
discussions(first: 5) {
edges {
node {
# The value below is the discussion-id
id
title
category {
id
name
}
body
id
}
}
}
}
}
{
"data": {
"repository": {
"discussions": {
"edges": [
{
"node": {
// This is the discussion-id
"id": "D_kwdje64ife75s9o",
"title": "Test Topic Title - Insert Question Here",
"category": {
"id": "DIC_kwSWEbhiT23EW-rr",
"name": "Q&A"
},
"body": "This is the body of the discussion topic"
}
}
]
}
}
}
}
Example workflow can be found here.