From 1c57e9d1b95d69f5412fbaa5ad49c0acdc5fe35c Mon Sep 17 00:00:00 2001 From: Robert Duncan <74115869+robproject@users.noreply.github.com> Date: Sat, 21 Oct 2023 23:08:11 -0700 Subject: [PATCH] chore: update docs test empty html (#5) * chore: update docs test empty html * fix: omit comment when empty * chore: modify comment logic * fix: skip whitespace comment * chore: test regex approach --- .github/workflows/main.yaml | 7 +++++++ README.md | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6c706ba..cc33e57 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -42,6 +42,13 @@ jobs: script: | const fs = require('fs'); const output = fs.readFileSync('diff_output.html', 'utf8'); + + const regex = /
\s*<\/pre>/;
+            if (regex.test(output)) {
+              console.log("Output within 
 tag is empty or only contains whitespace. Skipping comment post.");
+              return;
+            }
+
             const issue_number = context.issue.number;
             github.rest.issues.createComment({
               owner: context.repo.owner,
diff --git a/README.md b/README.md
index cc5aff2..a5ab720 100644
--- a/README.md
+++ b/README.md
@@ -2,11 +2,11 @@
 
 ## Usage
 ### Local Testing
-1. Change or delete any json files located in /test_files
+1. Change or delete any json files located in `/test_files`
 2. `bash ./run.sh`
 
 ### CI Implementation
-Copy the file `.github/workflows/main.yaml` along with its parent directories into the root folder of a custom app. Change the branch on lines 4 and 6 if applicable. Keep the `1` on line 23 to print table diffs or change it to `0` for trees.
+Copy the file `.github/workflows/main.yaml` along with its parent directories into the root folder of a custom app. Change the branch on lines 4 and 6 if applicable. Keep the `1` on line 24 to print table diffs or change it to `0` for trees.
 
 ## Output
 Runner terminals will show JSON file names and diff content for any modified files, and names of deleted files. If any schema changes (changed JSON) are present, the workflow will fail.