diff --git a/.github/workflows/check_pr_comments.yml b/.github/workflows/check_pr_comments.yml new file mode 100644 index 00000000000000..1c5007ff7185d8 --- /dev/null +++ b/.github/workflows/check_pr_comments.yml @@ -0,0 +1,34 @@ +name: Check PR Comments Message + +on: + pull_request: + types: [opened, synchronize] + +jobs: + Check: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Check PR body for comments + uses: actions/github-script@v7 + with: + script: | + const prNumber = context.payload.pull_request.number; + const prBody = context.payload.pull_request.body; + + const commentRegex = //; + const hasComment = commentRegex.test(prBody); + if (hasComment) { + const comment = "This pull request contains `` comments."; + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + body: comment + }); + } + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}