4848 - name : Checkout code
4949 uses : actions/checkout@v4
5050
51+ - name : Resolve deployed commit metadata
52+ id : preview_commit
53+ run : |
54+ echo "deployed_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
55+ echo "head_sha=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
56+
5157 - name : Install preview tooling
5258 run : npm install -g @railway/cli workos
5359
@@ -165,6 +171,8 @@ jobs:
165171 event_type: "inspector_preview_requested",
166172 client_payload: {
167173 branch: "${{ steps.meta.outputs.branch }}",
174+ inspector_sha: "${{ steps.preview_commit.outputs.deployed_sha }}",
175+ inspector_head_sha: "${{ steps.preview_commit.outputs.head_sha }}",
168176 inspector_repo: context.repo.owner + "/" + context.repo.repo,
169177 inspector_pr_number: context.payload.pull_request.number,
170178 inspector_environment: "${{ steps.meta.outputs.environment }}",
@@ -177,21 +185,35 @@ jobs:
177185 env :
178186 PREVIEW_URL : ${{ steps.preview_domain.outputs.url }}
179187 BACKEND_MODE : ${{ steps.backend_branch.outputs.exists == 'true' && 'preview requested' || 'staging fallback' }}
188+ PREVIEW_DEPLOYED_SHA : ${{ steps.preview_commit.outputs.deployed_sha }}
189+ PREVIEW_HEAD_SHA : ${{ steps.preview_commit.outputs.head_sha }}
180190 with :
181191 script : |
182192 const marker = process.env.PREVIEW_COMMENT_MARKER;
183193 const previewUrl = process.env.PREVIEW_URL;
184194 const backendMode = process.env.BACKEND_MODE;
195+ const deployedSha = process.env.PREVIEW_DEPLOYED_SHA;
196+ const headSha = process.env.PREVIEW_HEAD_SHA;
185197 const issue_number = context.payload.pull_request.number;
198+ const commitLink = (sha) =>
199+ sha
200+ ? `[${sha.slice(0, 7)}](https://github.com/${context.repo.owner}/${context.repo.repo}/commit/${sha})`
201+ : null;
186202 const bodyLines = [
187203 marker,
188204 "### Internal preview",
189205 previewUrl
190206 ? `Preview URL: ${previewUrl}`
191207 : "Preview URL will appear in Railway after the deploy finishes.",
208+ deployedSha
209+ ? `Deployed commit: ${commitLink(deployedSha)}`
210+ : null,
211+ headSha && headSha !== deployedSha
212+ ? `PR head commit: ${commitLink(headSha)}`
213+ : null,
192214 `Backend target: ${backendMode}.`,
193215 "Access is employee-only in non-production environments.",
194- ];
216+ ].filter(Boolean) ;
195217 const body = bodyLines.join("\n");
196218
197219 const comments = await github.paginate(github.rest.issues.listComments, {
@@ -240,7 +262,13 @@ jobs:
240262 - name : Checkout default branch
241263 uses : actions/checkout@v4
242264 with :
243- ref : ${{ github.event.client_payload.inspector_git_ref || 'main' }}
265+ ref : ${{ github.event.client_payload.inspector_sha || github.event.client_payload.inspector_git_ref || github.event.client_payload.branch || 'main' }}
266+
267+ - name : Resolve deployed commit metadata
268+ id : preview_commit
269+ run : |
270+ echo "deployed_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
271+ echo "head_sha=${{ github.event.client_payload.inspector_head_sha || '' }}" >> "$GITHUB_OUTPUT"
244272
245273 - name : Install preview tooling
246274 run : npm install -g @railway/cli workos
@@ -363,6 +391,8 @@ jobs:
363391 event_type: "inspector_preview_requested",
364392 client_payload: {
365393 branch: "${{ steps.meta.outputs.branch }}",
394+ inspector_sha: "${{ steps.preview_commit.outputs.deployed_sha }}",
395+ inspector_head_sha: "${{ steps.preview_commit.outputs.head_sha || steps.preview_commit.outputs.deployed_sha }}",
366396 inspector_repo: context.repo.owner + "/" + context.repo.repo,
367397 inspector_pr_number: "0",
368398 inspector_environment: "${{ steps.meta.outputs.environment }}",
@@ -379,11 +409,15 @@ jobs:
379409 PREVIEW_URL : ${{ steps.preview_domain.outputs.url }}
380410 BACKEND_REPO_FULL : ${{ github.event.client_payload.backend_repo }}
381411 BACKEND_PR_NUMBER : ${{ github.event.client_payload.backend_pr_number }}
412+ PREVIEW_DEPLOYED_SHA : ${{ steps.preview_commit.outputs.deployed_sha }}
413+ PREVIEW_HEAD_SHA : ${{ steps.preview_commit.outputs.head_sha || steps.preview_commit.outputs.deployed_sha }}
382414 with :
383415 github-token : ${{ secrets.BACKEND_PREVIEW_DISPATCH_TOKEN }}
384416 script : |
385417 const marker = process.env.PREVIEW_COMMENT_MARKER;
386418 const previewUrl = process.env.PREVIEW_URL;
419+ const deployedSha = process.env.PREVIEW_DEPLOYED_SHA;
420+ const headSha = process.env.PREVIEW_HEAD_SHA;
387421 if (process.env.BACKEND_REPO_FULL !== process.env.BACKEND_REPO) {
388422 core.setFailed(
389423 `backend_repo '${process.env.BACKEND_REPO_FULL}' does not match allowed repo '${process.env.BACKEND_REPO}'`
@@ -402,9 +436,15 @@ jobs:
402436 previewUrl
403437 ? `Preview URL: ${previewUrl}`
404438 : "Preview URL will appear in Railway after the deploy finishes.",
439+ deployedSha
440+ ? `Deployed commit: [${deployedSha.slice(0, 7)}](https://github.com/${context.repo.owner}/${context.repo.repo}/commit/${deployedSha})`
441+ : null,
442+ headSha && headSha !== deployedSha
443+ ? `PR head commit: [${headSha.slice(0, 7)}](https://github.com/${context.repo.owner}/${context.repo.repo}/commit/${headSha})`
444+ : null,
405445 "Backend target: Convex preview requested (falls back to staging if deploy fails).",
406446 "Access is employee-only in non-production environments.",
407- ];
447+ ].filter(Boolean) ;
408448 const body = bodyLines.join("\n");
409449 const comments = await github.paginate(github.rest.issues.listComments, {
410450 owner,
@@ -512,6 +552,14 @@ jobs:
512552 steps :
513553 - name : Checkout code
514554 uses : actions/checkout@v4
555+ with :
556+ ref : ${{ github.event.client_payload.inspector_sha || github.event.client_payload.inspector_git_ref || github.event.client_payload.branch || 'main' }}
557+
558+ - name : Resolve deployed commit metadata
559+ id : preview_commit
560+ run : |
561+ echo "deployed_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
562+ echo "head_sha=${{ github.event.client_payload.inspector_head_sha || '' }}" >> "$GITHUB_OUTPUT"
515563
516564 - name : Install preview tooling
517565 run : npm install -g @railway/cli workos
@@ -604,12 +652,16 @@ jobs:
604652 env :
605653 PREVIEW_URL : ${{ steps.preview_domain.outputs.url }}
606654 BACKEND_MODE : ${{ steps.backend_target.outputs.backend_mode }}
655+ PREVIEW_DEPLOYED_SHA : ${{ steps.preview_commit.outputs.deployed_sha }}
656+ PREVIEW_HEAD_SHA : ${{ steps.preview_commit.outputs.head_sha }}
607657 CROSS_REPO_TOKEN : ${{ secrets.BACKEND_PREVIEW_DISPATCH_TOKEN }}
608658 BACKEND_REPO : ${{ vars.MCPJAM_BACKEND_REPO || 'MCPJam/mcpjam-backend' }}
609659 with :
610660 github-token : ${{ (github.event.client_payload.comment_issue_owner || '') != '' && secrets.BACKEND_PREVIEW_DISPATCH_TOKEN || github.token }}
611661 script : |
612662 const marker = process.env.PREVIEW_COMMENT_MARKER;
663+ const deployedSha = process.env.PREVIEW_DEPLOYED_SHA;
664+ const headSha = process.env.PREVIEW_HEAD_SHA;
613665 const p = context.payload.client_payload;
614666 const issueOwner = p.comment_issue_owner;
615667 const issueRepo = p.comment_issue_repo;
@@ -618,6 +670,10 @@ jobs:
618670 : Number(p.inspector_pr_number);
619671 const owner = issueOwner || context.repo.owner;
620672 const repo = issueRepo || context.repo.repo;
673+ const commitLink = (sha) =>
674+ sha
675+ ? `[${sha.slice(0, 7)}](https://github.com/${context.repo.owner}/${context.repo.repo}/commit/${sha})`
676+ : null;
621677
622678 // Fail explicitly if cross-repo commenting was requested but token is missing
623679 if (issueOwner && !process.env.CROSS_REPO_TOKEN) {
@@ -651,9 +707,15 @@ jobs:
651707 process.env.PREVIEW_URL
652708 ? `Preview URL: ${process.env.PREVIEW_URL}`
653709 : "Preview URL will appear in Railway after the deploy finishes.",
710+ deployedSha
711+ ? `Deployed commit: ${commitLink(deployedSha)}`
712+ : null,
713+ headSha && headSha !== deployedSha
714+ ? `PR head commit: ${commitLink(headSha)}`
715+ : null,
654716 `Backend target: ${process.env.BACKEND_MODE}.`,
655717 "Access is employee-only in non-production environments.",
656- ];
718+ ].filter(Boolean) ;
657719 const body = bodyLines.join("\n");
658720
659721 const comments = await github.paginate(github.rest.issues.listComments, {
0 commit comments