Skip to content

Commit

Permalink
Add discussion comment workflow (#1945)
Browse files Browse the repository at this point in the history
* Add a bot to autocomment on workflow

* Use github markdown warning syntax

* Add a multiline warning

* Change happy coding to happy SLEAPing

Co-authored-by: Talmo Pereira <[email protected]>

---------

Co-authored-by: roomrys <[email protected]>
Co-authored-by: Talmo Pereira <[email protected]>
  • Loading branch information
3 people authored Sep 6, 2024
1 parent 83d6bc0 commit 983a784
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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
});

0 comments on commit 983a784

Please sign in to comment.