Skip to content

Comment on New Discussions and Issues #2

Comment on New Discussions and Issues

Comment on New Discussions and Issues #2

Workflow file for this run

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
});