Skip to content

chore: update docs test empty html #60

chore: update docs test empty html

chore: update docs test empty html #60

Workflow file for this run

name: Diff Sample
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
Diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
ref: ${{ github.ref }}
- name: Setup requirements
run: |
pip install rich
pip install json_source_map
# wget https://raw.githubusercontent.com/robproject/fsjd/main/frappe_schema_json_diff.py
echo "GIT_EXTERNAL_DIFF=./frappe_schema_json_diff.py" >> $GITHUB_ENV
echo "TABLE_MODE=1" >> $GITHUB_ENV
- name: Diff
run: |
git --no-pager diff HEAD~1 HEAD > diff_output.txt
cat diff_output.txt
- name: Convert ansi to html
if: github.event_name == 'pull_request'
run: |
pip install ansi2html
cat diff_output.txt | ansi2html > diff_output.html
sed -i -n '/<pre class="ansi2html-content">/,/<\/pre>/p' diff_output.html
- name: Post comment
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');
const regex = /<pre class="ansi2html-content">\s*<\/pre>/;
if (regex.test(output)) {
console.log("Output within <pre> 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,
repo: context.repo.repo,
issue_number: issue_number,
body: output,
});