For this moment, this GitHub Actions don't work properly like I would like. When GitHub add the possibility to add and/or edit comments in Discussions, i will update the project.
I started this Action because I thinked that it is a good idea to have a moderate tool in Discussions part with the toxicity of comments. So I did it thinking it would be feasible, but when I got to the end of the code part, I couldn't figure out how to create/edit comments.
A GitHub action that detects toxic messages in Discussions.
No Toxic Discussions uses Perspective API by Jigsaw from Google.
Create the .github/workflows/NoToxicDiscussions.yml
file with the following configuration :
name: No Toxic Discussions Here
on:
discussion:
# created type can be marked as an error BUT IT'S WORK. See the docs :
# https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#discussion
types: [ created, opened, edited, answered ]
discussion_comment:
types: [ created, edited ]
jobs:
CheckIfToxicContent:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PERSPECTIVE_API_KEY: ${{ secrets.PERSPECTIVE_API_KEY }}
- name: Install dependencies
run: |
yarn install
yarn add @actions/core @actions/github
- name: Run the script
run: |
yarn run start
PERSPECTIVE_API_TOKEN |
---|
Required โ This Action use Perspective API. โ Get your key here โก |
When anyone create a new comment in a discussion or create a new discussion, the script will check if the comment is toxic. If the author edit this comment, the Actions run again.
Output workflow :
You can test the test/SampleRequestPerspectiveAPI.js file.
- Clone this project
- Create an .env file and put your GOOGLE_API_TOKEN
- Write a bad comment at CONTENT (line 6)
- Run with
yarn run test
ornpm run test
!
Anyone can contribute to this GitHub Action. Feel free to discuss it in the section provided for this purpose. ๐๐ผ Read the contribution Guidelines first. You can also contribute to share this repository. ๐
This Action is only for english language for the moment. Maybe updates in the future add others languages. We are based on Perspective API with only TOXICITY attribute name to detect bad comments, see the available languages on the official website
- ๐ฃ News : Follow me on Twitter
- ๐ See my website !
- ๐จ Send me a email !
Feel free to help me for the maintenance of this project !