Skip to content

Commit

Permalink
fix: skip whitespace comment
Browse files Browse the repository at this point in the history
  • Loading branch information
robproject committed Oct 22, 2023
1 parent 55b76b8 commit 168ba1a
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,17 @@ jobs:
cat diff_output.txt | ansi2html > diff_output.html
sed -i -n '/<pre class="ansi2html-content">/,/<\/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' && steps.check_file.outputs.hasContent == 'true'
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const output = fs.readFileSync('diff_output.html', 'utf8');
if (!output.trim()) { // Check if the output only contains whitespace
console.log("Output is empty or only contains whitespace. Skipping comment post.");
return;
}
const issue_number = context.issue.number;
github.rest.issues.createComment({
owner: context.repo.owner,
Expand Down

0 comments on commit 168ba1a

Please sign in to comment.