diff --git a/README.md b/README.md index 06b3e63..523ed60 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Since posting comments on GitHub requires write permission you need two create 2 In the second config file you need to specify 2 params: - `token`: your GitHub token -- `datapath`: a path to a yaml file with a config that contains `prependMsg` and `checks` props. `prependMsg` is a message that prepends to every message of the bot. Keep empty if not needed. **By default** it's `🗯️ [pull-request-auto-reviewer]:` (as per screenshot). `checks` props consists of pairs of `paths` and `message` keys. `paths` dedicated to specify path(s) of changes that would trigger posting of followed `message` as a pull request comment. In case of multiple `paths` they should be separated by a comma. `message` could be a simple string or a markdown. [Example](https://github.com/pshergie/pull-request-auto-reviewer/blob/main/docs/data.yml) +- `data-path`: a path to a yaml file with a config that contains `prependMsg` and `checks` props. `prependMsg` is a message that prepends to every message of the bot. Keep empty if not needed. **By default** it's `🗯️ [pull-request-auto-reviewer]:` (as per screenshot). `checks` props consists of pairs of `paths` and `message` keys. `paths` dedicated to specify path(s) of changes that would trigger posting of followed `message` as a pull request comment. In case of multiple `paths` they should be separated by a comma. `message` could be a simple string or a markdown. Known problems: diff --git a/package.json b/package.json index 6bef123..1179841 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gh-actions-test", - "version": "1.11", + "version": "1.11.1", "description": "", "author": "pshergie", "license": "ISC", diff --git a/src/index.js b/src/index.js index 105221e..7a81392 100644 --- a/src/index.js +++ b/src/index.js @@ -14,6 +14,13 @@ async function run() { fs.readFileSync(dataPath, "utf8"), ); const { prependMsg } = prependData; + + if (!checksData?.checks) { + console.log('checksData: ', checksData); + + throw new Error('The comments data is empty or incorrect'); + } + const checks = checksData?.checks?.map((config) => ({ ...config, paths: config.paths.split(",").map((p) => p.trim()), @@ -26,7 +33,7 @@ async function run() { const pullNumber = parseInt(fs.readFileSync(artifactPath + 'pr_number.txt', "utf8"), 10); const diffFilesPaths = fs.readFileSync(artifactPath + 'pr_files_diff.txt', "utf8")?.split('\n').filter(Boolean); - checks.map( + checks?.map( async ({ paths, message }) => await postComment( prependMsg,