-
Notifications
You must be signed in to change notification settings - Fork 3
63 lines (50 loc) · 1.75 KB
/
main.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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,
});