-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add discussion comment workflow (#1945)
* 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
1 parent
83d6bc0
commit 983a784
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
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
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 | ||
}); |