@@ -89302,7 +89302,6 @@ var __importStar = (this && this.__importStar) || (function () {
8930289302Object.defineProperty(exports, "__esModule", ({ value: true }));
8930389303exports.postInitialComment = postInitialComment;
8930489304exports.updateComment = updateComment;
89305- exports.postComment = postComment;
8930689305const github = __importStar(__nccwpck_require__(75380));
8930789306const logger_1 = __nccwpck_require__(61661);
8930889307const COMMENT_MARKER = '<!-- auto-pr-screenshots -->';
@@ -89320,14 +89319,35 @@ async function postInitialComment(options) {
8932089319 logger_1.commentLogger.info(`💬 Posting initial comment to PR #${prNumber}`);
8932189320 try {
8932289321 const commentBody = generateInitialCommentBody(commitSha);
89323- const { data: comment } = await octokit.rest.issues.createComment({
89322+ // Find existing comment
89323+ const { data: comments } = await octokit.rest.issues.listComments({
8932489324 owner,
8932589325 repo,
8932689326 issue_number: prNumber,
89327- body: commentBody,
8932889327 });
89329- logger_1.commentLogger.success('✅ Created initial comment');
89330- return comment.id;
89328+ const existingComment = comments.find((comment) => comment.body?.includes(COMMENT_MARKER) && comment.user?.type === 'Bot');
89329+ if (existingComment) {
89330+ // Update existing comment
89331+ await octokit.rest.issues.updateComment({
89332+ owner,
89333+ repo,
89334+ comment_id: existingComment.id,
89335+ body: commentBody,
89336+ });
89337+ logger_1.commentLogger.success('✅ Updated existing comment with initial status');
89338+ return existingComment.id;
89339+ }
89340+ else {
89341+ // Create new comment
89342+ const { data: comment } = await octokit.rest.issues.createComment({
89343+ owner,
89344+ repo,
89345+ issue_number: prNumber,
89346+ body: commentBody,
89347+ });
89348+ logger_1.commentLogger.success('✅ Created initial comment');
89349+ return comment.id;
89350+ }
8933189351 }
8933289352 catch (error) {
8933389353 logger_1.commentLogger.error('Failed to post initial comment:', error instanceof Error ? error.message : String(error));
@@ -89356,53 +89376,6 @@ async function updateComment(commentId, screenshots, errors, options, status) {
8935689376 logger_1.commentLogger.error('Failed to update comment:', error instanceof Error ? error.message : String(error));
8935789377 }
8935889378}
89359- async function postComment(screenshots, errors, options) {
89360- const { token, context, config } = options;
89361- // Only post comments on pull requests
89362- if (context.eventName !== 'pull_request' || !context.payload.pull_request) {
89363- logger_1.commentLogger.warn('Not in a pull request context, skipping comment');
89364- return;
89365- }
89366- const octokit = github.getOctokit(token);
89367- const { owner, repo } = context.repo;
89368- const prNumber = context.payload.pull_request.number;
89369- logger_1.commentLogger.info(`💬 Posting comment to PR #${prNumber}`);
89370- try {
89371- // Find existing comment
89372- const { data: comments } = await octokit.rest.issues.listComments({
89373- owner,
89374- repo,
89375- issue_number: prNumber,
89376- });
89377- const existingComment = comments.find((comment) => comment.body?.includes(COMMENT_MARKER) && comment.user?.type === 'Bot');
89378- // Generate comment body
89379- const commentBody = generateCommentBody(screenshots, errors, context, config, options.showAttribution);
89380- if (existingComment) {
89381- // Update existing comment
89382- await octokit.rest.issues.updateComment({
89383- owner,
89384- repo,
89385- comment_id: existingComment.id,
89386- body: commentBody,
89387- });
89388- logger_1.commentLogger.success('✅ Updated existing comment');
89389- }
89390- else {
89391- // Create new comment
89392- await octokit.rest.issues.createComment({
89393- owner,
89394- repo,
89395- issue_number: prNumber,
89396- body: commentBody,
89397- });
89398- logger_1.commentLogger.success('✅ Created new comment');
89399- }
89400- }
89401- catch (error) {
89402- logger_1.commentLogger.error('Failed to post comment:', error instanceof Error ? error.message : String(error));
89403- throw error;
89404- }
89405- }
8940689379function generateInitialCommentBody(commitSha) {
8940789380 let body = `${COMMENT_MARKER}\n`;
8940889381 body += '## 📸 Auto PR Screenshots\n\n';
@@ -89420,7 +89393,7 @@ function generateCommentBody(screenshots, errors, context, config, showAttributi
8942089393 }
8942189394 else {
8942289395 body += `✅ Screenshot capture complete for commit \`${commitSha}\`\n\n`;
89423- body += `*Completed: ${timestamp}*\n\n`;
89396+ body += `*Completed <relative-time datetime=" ${timestamp}">${timestamp}</relative-time> *\n\n`;
8942489397 }
8942589398 if (screenshots.length === 0 && errors.length === 0) {
8942689399 body += `⚠️ No screenshots were captured. Check the [action logs](${runUrl}) for details.\n`;
0 commit comments