πΆ Disclaimer : Read this before using it
For the moment, this GitHub Action doesn't work as properly as I would like. When GitHub adds the possibility to add and/or edit comments in Discussions, I will update the project.
I started this Action because I thought that it is a good idea to have a moderation tool in the 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.
No Toxic Discussions
A GitHub action that detects toxic messages in Discussions.
No Toxic Discussions uses the Perspective API by Jigsaw from Google.
Workflow
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 WORKS. 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 startInputs
PERSPECTIVE_API_TOKEN |
|---|
| Required β This Action use the Perspective API. β Get your key here β‘ |
How it works
When anyone creates a new comment in a discussion or creates a new discussion, the script will check if the comment is toxic. If the author edits their comment, the Action will run again.
Output workflow :
Test locally
You can test the test/SampleRequestPerspectiveAPI.js file.
- Clone this project
- Create a .env file and put your GOOGLE_API_TOKEN
- Write a bad comment at CONTENT (line 6)
- Run with
yarn run testornpm run test!
Contribute
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 by sharing this repository. π
Languages Supported
This Action is only for the english language for the moment. Maybe updates in the future will 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
Additional informations
- π£ News : Follow me on Twitter
- π See my website !
- π¨ Send me a email !
Donate
Feel free to help me for the maintenance of this project !
