|
98 | 98 | with:
|
99 | 99 | github-token: ${{ secrets.GITHUB_TOKEN }}
|
100 | 100 | 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