Skip to content

Commit

Permalink
add debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksim Minko committed May 30, 2024
1 parent 8b3aeb9 commit 8d3c40f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gh-actions-test",
"version": "1.11",
"version": "1.11.1",
"description": "",
"author": "pshergie",
"license": "ISC",
Expand Down
9 changes: 8 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand All @@ -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,
Expand Down

0 comments on commit 8d3c40f

Please sign in to comment.