@@ -2,9 +2,9 @@ name: Semantic Diff
22
33# Renders the commit records of each pull request (scripts/commitRecords.js)
44# as a review page on the CDN, and comments them on the pull request as
5- # Markdown (scripts/recordMarkdown.js) with the page's link. The page holds
6- # every commit; the comment holds the commits a push added, or every commit
7- # when the pull request is opened or reopened or its branch is force-pushed .
5+ # Markdown (scripts/recordMarkdown.js) with the page's link. A pull request
6+ # has one such comment, which each push updates in place to hold every
7+ # commit, so the pull request shows its current records in one place .
88#
99# A pull request from a branch of this repository runs on pull_request, with
1010# the workflow and renderer of its merge into the base branch: GitHub takes
4242 PR_NUMBER : ${{ github.event.pull_request.number }}
4343 PR_TITLE : ${{ github.event.pull_request.title }}
4444 BASE_SHA : ${{ github.event.pull_request.base.sha }}
45- # The head before a push; empty when the pull request is opened or
46- # reopened.
47- BEFORE_SHA : ${{ github.event.action == 'synchronize' && github.event.before || '' }}
4845 steps :
4946 - name : Checkout renderer
5047 uses : actions/checkout@v7
@@ -55,25 +52,15 @@ jobs:
5552 persist-credentials : false
5653
5754 - name : Render semantic diff
58- id : render
5955 run : |
6056 git fetch --no-tags --filter=blob:none origin "refs/pull/${PR_NUMBER}/head:refs/heads/pr-${PR_NUMBER}"
6157 base=$(git merge-base "$BASE_SHA" "pr-${PR_NUMBER}")
6258 head=$(git rev-parse --short=9 "pr-${PR_NUMBER}")
6359 # The query string names the rendered commit, so each push gets a
6460 # URL that no cache has seen.
6561 url="https://cdn.rescript-lang.org/semantic-diff/pr-${PR_NUMBER}/index.html?v=${head}"
66- # A push that keeps the previous head adds commits on top of it:
67- # the comment holds those. After a force push the previous head is
68- # no ancestor (nor, from a fork, fetched), and the comment holds
69- # every commit.
70- since=()
71- if [ -n "$BEFORE_SHA" ] && git merge-base --is-ancestor "$BEFORE_SHA" "pr-${PR_NUMBER}" 2>/dev/null; then
72- since=(--since "$BEFORE_SHA")
73- fi
7462 mkdir -p semantic-diff
75- node scripts/commitRecords.js --out semantic-diff/index.html --markdown semantic-diff/comment.md "${since[@]}" --url "$url" --pr "$PR_NUMBER" --title "$PR_TITLE" "${base}..pr-${PR_NUMBER}"
76- echo "head=${head}" >> "$GITHUB_OUTPUT"
63+ node scripts/commitRecords.js --out semantic-diff/index.html --markdown semantic-diff/comment.md --url "$url" --pr "$PR_NUMBER" --title "$PR_TITLE" "${base}..pr-${PR_NUMBER}"
7764
7865 - name : Setup Rclone
7966 uses : cometkim/rclone-actions/setup-rclone@8d9c6b95341f7698609deee65c3d62af42893288 # main, 2025-06-18
@@ -91,14 +78,12 @@ jobs:
9178 - name : Upload semantic diff
9279 run : rclone copyto --s3-no-check-bucket semantic-diff/index.html "rescript:cdn-assets/semantic-diff/pr-${PR_NUMBER}/index.html"
9380
94- # A push that adds only merge commits writes no comment.
9581 - name : Comment semantic diff
96- if : hashFiles('semantic-diff/comment.md') != ''
9782 uses : thollander/actions-comment-pull-request@v3
9883 with :
9984 pr-number : ${{ github.event.pull_request.number }}
100- # Each push gets its own comment, so the comments of earlier pushes
101- # stay; a re-run of the same head updates its comment .
102- comment-tag : semantic-diff-${{ steps.render.outputs.head }}
85+ # The pull request's one comment, edited in place on each push;
86+ # edits notify no one .
87+ comment-tag : semantic-diff
10388 mode : upsert
10489 file-path : semantic-diff/comment.md
0 commit comments