Skip to content

Commit 5dd39db

Browse files
committed
Add comment sha to the deployment comment
1 parent cdf2ad0 commit 5dd39db

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

.github/workflows/cloudflare-preview.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ jobs:
7272
const url = "${{ steps.deploy.outputs.deployment-url }}";
7373
const commentMarker = "🚀 Preview deployment available at:";
7474
75+
// Get commit SHA based on event type
76+
let commitSha;
77+
if ('${{ github.event_name }}' === 'pull_request') {
78+
commitSha = '${{ github.event.pull_request.head.sha }}';
79+
} else {
80+
// For workflow_dispatch, get the SHA from the current commit
81+
commitSha = '${{ github.sha }}';
82+
}
83+
7584
// Get all comments on the PR
7685
const comments = await github.rest.issues.listComments({
7786
issue_number: prNumber,
@@ -85,7 +94,7 @@ jobs:
8594
comment.body.includes(commentMarker)
8695
);
8796
88-
const commentBody = `${commentMarker} [${url}](${url})`;
97+
const commentBody = `${commentMarker} [${url}](${url}) (commit: ${commitSha})`;
8998
9099
if (existingComment) {
91100
// Update existing comment

0 commit comments

Comments
 (0)