From 55b76b8ee821344b339b3d6892664be107fc6de0 Mon Sep 17 00:00:00 2001 From: Robert Duncan Date: Sat, 21 Oct 2023 22:54:25 -0700 Subject: [PATCH] chore: modify comment logic --- .github/workflows/main.yaml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index f9cbec0..3567740 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -35,8 +35,19 @@ jobs: cat diff_output.txt | ansi2html > diff_output.html sed -i -n '/
/,/<\/pre>/p' diff_output.html
       
+      - name: Check for content
+        if: github.event_name == 'pull_request'
+        id: check_file
+        run: |
+            content=$(tr -d "[:space:]" < diff_output.html)
+            if [[ -n "$content" ]]; then
+              echo "::set-output name=hasContent::true"
+            else
+              echo "::set-output name=hasContent::false"
+            fi
+      
       - name: Post comment
-        if: github.event_name == 'pull_request' && $(grep -qE "\S" diff_output.html)
+        if: github.event_name == 'pull_request' && steps.check_file.outputs.hasContent == 'true'
         uses: actions/github-script@v6
         with:
           script: |