Skip to content

abhishekjog/comment-scanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

If you want to scan each PR and issue comment for prohibited text while it is being posted on any branch in the repository, you can add github action using this repo to run a scan on the comment to either let it post or delete it if it contains the prohibited text.

Sample syntax for actions yml file:
e.g. I do not want any of the comments posted if they leak my domain name 

name: comment example
on: issue_comment
jobs:
  pr_commented:
    runs-on: ubuntu-latest
    steps:
      - name: Create comment
        uses: abhishekjog/comment-scanner@t2
        id: create
        with:
          type: create
          body: ${{ github.event.comment.body }}
          issue_number: ${{ github.event.issue.number }}
          token: ${{ secrets.GITHUB_TOKEN }}
          bad_text: "mydomain.com"
          comment_id: ${{ github.event.comment.id }}

      - name: Update comment
        uses: abhishekjog/comment-scanner@t2
        with:
          type: edit
          body: ${{ github.event.comment.body }}
          #comment_id: ${{ steps.create.outputs.id }}
          token: ${{ secrets.GITHUB_TOKEN }}
          bad_text: "mydomain.com"
          comment_id: ${{ github.event.comment.id }}

With above action in place, every issue or PR comment will be scaned for presence of bad text.
As GitHub works, the comment is posted first, then the action bot runs and deletes the comment if needed.