Skip to content

Commit a08db66

Browse files
committed
fix change detection
1 parent 1fb4847 commit a08db66

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

.github/workflows/synchronize_bindings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
run: |
3333
if [[ -n $(git status --porcelain) ]]; then
3434
echo "changes=true" >> "$GITHUB_OUTPUT"
35-
git diff > bindings.diff
35+
git diff --text > bindings.diff
3636
echo "Diff created:"
3737
cat bindings.diff
3838
else

.github/workflows/synchronize_bindings_check_diff.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ jobs:
1515
env:
1616
DIFF_ARTIFACT: bindings.diff
1717
PR_EVENT: event-bindings.json
18+
EVENT_FILE: event.json
1819
steps:
19-
- name: Download Benchmark Results
20+
- name: Download Diff Results
2021
uses: dawidd6/action-download-artifact@v6
2122
with:
2223
name: ${{ env.DIFF_ARTIFACT }}
@@ -31,13 +32,48 @@ jobs:
3132
with:
3233
script: |
3334
let fs = require('fs');
34-
let prEvent = JSON.parse(fs.readFileSync(process.env.PR_EVENT, {encoding: 'utf8'}));
35+
let prEvent = JSON.parse(fs.readFileSync(process.env.EVENT_FILE, {encoding: 'utf8'}));
3536
core.exportVariable("PR_HEAD", prEvent.pull_request.head.ref);
3637
core.exportVariable("PR_BASE", prEvent.pull_request.base.ref);
3738
core.exportVariable("PR_BASE_SHA", prEvent.pull_request.base.sha);
3839
core.exportVariable("PR_NUMBER", prEvent.number);
3940
core.exportVariable("HEAD_REPO", prEvent.pull_request.head.repo.full_name);
4041
core.exportVariable("HEAD_REPO_URL", prEvent.pull_request.head.repo.git_url);
42+
43+
- name: Build Collapsible Diff Comment
44+
id: build_comment
45+
continue-on-error: true
46+
shell: bash
47+
run: |
48+
echo '### 🔍 Binding Differences Detected' > comment.md
49+
echo '' >> comment.md
50+
echo '> The following changes were detected in generated bindings:' >> comment.md
51+
echo '' >> comment.md
52+
53+
# Build collapsible sections per file
54+
awk '
55+
/^diff --git/ {
56+
if (file != "") print "</pre></details>" >> "comment.md"
57+
file=$4
58+
gsub(/^a\//, "", file)
59+
print "<details><summary>" file "</summary><pre>" >> "comment.md"
60+
next
61+
}
62+
{ print $0 >> "comment.md" }
63+
END { if (file != "") print "</pre></details>" >> "comment.md" }
64+
' "${{ env.DIFF_ARTIFACT }}"
65+
66+
- name: Add or Update PR Comment with Diff
67+
id: pr_comment
68+
continue-on-error: true
69+
uses: peter-evans/create-or-update-comment@v4
70+
with:
71+
issue-number: ${{ env.PR_NUMBER }}
72+
body-path: comment.md
73+
edit-mode: replace
74+
token: ${{ secrets.GITHUB_TOKEN }}
75+
comment-identifier: bindings-diff
76+
4177
- name: Fail PR With URL
4278
uses: actions/github-script@v6
4379
with:

0 commit comments

Comments
 (0)