Comment on New Discussions and Issues #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Comment on New Discussions | |
on: | |
discussion: | |
types: [created] | |
jobs: | |
comment: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Post a multi-line comment on a new discussion | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const { owner, repo } = context.repo; | |
const discussion_id = context.payload.discussion.node_id; | |
const mutation = ` | |
mutation($discussionId: ID!, $body: String!) { | |
addDiscussionComment(input: {discussionId: $discussionId, body: $body}) { | |
comment { | |
id | |
} | |
} | |
} | |
`; | |
const body = ` | |
Thank you for starting a new discussion! | |
We appreciate your input and will review it soon. | |
> [!WARNING] | |
> A friendly reminder that this is a public forum. Please be cautious when clicking links, downloading files, or running scripts posted by others. | |
> | |
> - Always verify the credibility of links and code. | |
> - Avoid running scripts or installing files from untrusted sources. | |
> - If you're unsure, ask for clarification before proceeding. | |
Stay safe and happy SLEAPing! | |
Best regards, | |
The Team | |
`; | |
await github.graphql(mutation, { | |
discussionId: discussion_id, | |
body: body.trim() // Removes trailing/leading whitespace | |
}); |