From ee4e95c05528c4c2d26af40d0fa760e5df92d767 Mon Sep 17 00:00:00 2001 From: gkarthiks Date: Sun, 30 May 2021 01:11:41 -0700 Subject: [PATCH] fix: comments on issue for na file Signed-off-by: gkarthiks --- CHANGELOG.md | 2 ++ README.md | 11 +++++------ index.js | 19 ++++++++++++------- package.json | 2 +- 4 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3d5008e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,2 @@ +# 0.2.1 +* Errors in the action message if the words for restrictions are not defined and comment the same in the issue. \ No newline at end of file diff --git a/README.md b/README.md index 68494eb..5fd679f 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '12' - check-latest: true - name: NIL Reporter - uses: gkarthiks/nil-issue-reporter@0.2.0 + uses: gkarthiks/nil-issue-reporter@0.2.1 id: parseissue with: token: ${{ secrets.GITHUB_TOKEN }} @@ -43,4 +39,7 @@ This can be customized by changing it in the workflow YML file. For example, if ## Roadmaps * Auto validate for edit on the issue body * Extend for issue comments -* Extend for Pull Requests \ No newline at end of file +* Extend for Pull Requests + +## :warning: Important Note +As of now, this GitHub action is looking for a repo owner's defined words for restricting the non-inclusive language. Once the [Inclusive Naming](https://inclusivenaming.org) defines machine-parsable words for restriction, it will be used rather depending on the repo owner's list. \ No newline at end of file diff --git a/index.js b/index.js index 390f9d2..dc571f1 100644 --- a/index.js +++ b/index.js @@ -30,15 +30,20 @@ try { // Create RegEx for parsing the data and comparing the nil var nilWordArray = commaSeperatedStrToArray(nilFileData); - var regEx = new RegExp(nilWordArray.join('|'), 'gi'); + if (nilWordArray.length > 0) { + var regEx = new RegExp(nilWordArray.join('|'), 'gi'); - core.info("Issue number: "+issueNumber) - core.info("Issue title: "+issueTitle) - - validateAndComment(issueTitle, regEx, issueAuthor, ISSUE_TITLE_CTX, labelArray, githubToken, eventName); - validateAndComment(issueContext, regEx, issueAuthor, ISSUE_DESC_CTX, labelArray, githubToken, eventName); + core.info("Issue number: "+issueNumber) + core.info("Issue title: "+issueTitle) + + validateAndComment(issueTitle, regEx, issueAuthor, ISSUE_TITLE_CTX, labelArray, githubToken, eventName); + validateAndComment(issueContext, regEx, issueAuthor, ISSUE_DESC_CTX, labelArray, githubToken, eventName); + } else { + core.setFailed("Non Inclusive word list to restrict is not defined yet. Please define the words to be resricted."); + commentToIssue("The non-inclusive word list is not defined. Please ask your admin to add the list of words to restrict and then comment `/validate`.", labelArray, githubToken); + } } - + } catch (error) { core.setFailed(error.message); } diff --git a/package.json b/package.json index e1399e9..393ca4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nil-issue-reporter", - "version": "0.2.0", + "version": "0.2.1", "description": "Non-Inclusive Language(nil) issue reporter parses the issue content and write comment to the author on the issue.", "main": "index.js", "scripts": {