Skip to content

Commit e8ad3a9

Browse files
committed
update instead of post new comment
1 parent 5ab1ee5 commit e8ad3a9

File tree

1 file changed

+50
-6
lines changed

1 file changed

+50
-6
lines changed

.github/workflows/preview-release.yml

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,53 @@ jobs:
9898
with:
9999
github-token: ${{ secrets.GITHUB_TOKEN }}
100100
script: |
101-
await github.rest.issues.createComment({
102-
owner: context.repo.owner,
103-
repo: context.repo.repo,
104-
issue_number: context.issue.number,
105-
body: `🚀 **Preview release created!**\n\nsupabase-js CI tests have been automatically triggered on feature branch to verify compatibility.\n\n**Preview package:** \`${{ needs.preview.outputs.preview-url }}\`\n\nResults will be posted here once testing is complete.`
106-
});
101+
// Unique identifier for this bot's comments
102+
const commentIdentifier = '<!-- realtime-js-preview-status -->';
103+
104+
const body = `${commentIdentifier}
105+
🚀 **Preview release created!**
106+
107+
supabase-js CI tests have been automatically triggered on feature branch to verify compatibility.
108+
109+
**Preview package:** \`${{ needs.preview.outputs.preview-url }}\`
110+
111+
Results will be posted here once testing is complete.
112+
113+
---
114+
<sub>Last updated: ${new Date().toISOString()}</sub>`;
115+
116+
try {
117+
// First, try to find an existing comment from this bot
118+
const { data: comments } = await github.rest.issues.listComments({
119+
owner: context.repo.owner,
120+
repo: context.repo.repo,
121+
issue_number: context.issue.number
122+
});
123+
124+
// Look for a comment with our identifier
125+
const botComment = comments.find(comment =>
126+
comment.body && comment.body.includes(commentIdentifier)
127+
);
128+
129+
if (botComment) {
130+
// Update existing comment
131+
await github.rest.issues.updateComment({
132+
owner: context.repo.owner,
133+
repo: context.repo.repo,
134+
comment_id: botComment.id,
135+
body: body
136+
});
137+
console.log('Successfully updated existing preview status comment');
138+
} else {
139+
// Create new comment if none exists
140+
await github.rest.issues.createComment({
141+
owner: context.repo.owner,
142+
repo: context.repo.repo,
143+
issue_number: context.issue.number,
144+
body: body
145+
});
146+
console.log('Successfully posted new preview status comment');
147+
}
148+
} catch (error) {
149+
console.log('Failed to post/update comment:', error.message);
150+
}

0 commit comments

Comments
 (0)