@@ -11538,7 +11538,7 @@ function wrappy (fn, cb) {
1153811538
1153911539/***/ }),
1154011540
11541- /***/ 3580 :
11541+ /***/ 7071 :
1154211542/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
1154311543
1154411544"use strict";
@@ -11638,7 +11638,7 @@ Built from${appPr ? ` App PR Expensify/App#${appPr}` : ''}${mobileExpensifyPr ?
1163811638}
1163911639/** Comment on a single PR */
1164011640async function commentPR(REPO, PR, message) {
11641- console.log(`Posting test build comment on #${PR}`);
11641+ console.log(`Posting comment on #${PR}`);
1164211642 try {
1164311643 await GithubUtils_1.default.createComment(REPO, PR, message);
1164411644 console.log(`Comment created on #${PR} (${REPO}) successfully 🎉`);
@@ -11650,10 +11650,37 @@ async function commentPR(REPO, PR, message) {
1165011650 }
1165111651 }
1165211652}
11653+ async function hidePreviousComment(repo, issueNumber, commentPrefix) {
11654+ const comments = await GithubUtils_1.default.paginate(GithubUtils_1.default.octokit.issues.listComments, {
11655+ owner: CONST_1.default.GITHUB_OWNER,
11656+ repo,
11657+ // eslint-disable-next-line @typescript-eslint/naming-convention
11658+ issue_number: issueNumber,
11659+ // eslint-disable-next-line @typescript-eslint/naming-convention
11660+ per_page: 100,
11661+ }, (response) => response.data);
11662+ const previousComment = comments.findLast((comment) => comment.body?.startsWith(commentPrefix));
11663+ if (!previousComment) {
11664+ return;
11665+ }
11666+ await GithubUtils_1.default.graphql(`
11667+ mutation MinimizeComment($subjectId: ID!) {
11668+ minimizeComment(input: {classifier: OUTDATED, subjectId: $subjectId}) {
11669+ minimizedComment {
11670+ minimizedReason
11671+ }
11672+ }
11673+ }
11674+ `, {
11675+ subjectId: previousComment.node_id,
11676+ });
11677+ }
1165311678async function run() {
1165411679 const APP_PR_NUMBER = Number(core.getInput('APP_PR_NUMBER', { required: false }));
1165511680 const MOBILE_EXPENSIFY_PR_NUMBER = Number(core.getInput('MOBILE_EXPENSIFY_PR_NUMBER', { required: false }));
1165611681 const REPO = String(core.getInput('REPO', { required: true }));
11682+ const COMMENT_BODY = core.getInput('COMMENT_BODY', { required: false });
11683+ const COMMENT_PREFIX = core.getInput('COMMENT_PREFIX', { required: true });
1165711684 if (REPO !== CONST_1.default.APP_REPO && REPO !== CONST_1.default.MOBILE_EXPENSIFY_REPO) {
1165811685 core.setFailed(`Invalid repository used to place output comment: ${REPO}`);
1165911686 return;
@@ -11663,28 +11690,8 @@ async function run() {
1166311690 return;
1166411691 }
1166511692 const destinationPRNumber = REPO === CONST_1.default.APP_REPO ? APP_PR_NUMBER : MOBILE_EXPENSIFY_PR_NUMBER;
11666- const comments = await GithubUtils_1.default.paginate(GithubUtils_1.default.octokit.issues.listComments, {
11667- owner: CONST_1.default.GITHUB_OWNER,
11668- repo: REPO,
11669- // eslint-disable-next-line @typescript-eslint/naming-convention
11670- issue_number: destinationPRNumber,
11671- // eslint-disable-next-line @typescript-eslint/naming-convention
11672- per_page: 100,
11673- }, (response) => response.data);
11674- const testBuildComment = comments.find((comment) => comment.body?.startsWith(':test_tube::test_tube: Use the links below to test this adhoc build'));
11675- if (testBuildComment) {
11676- console.log('Found previous build comment, hiding it', testBuildComment);
11677- await GithubUtils_1.default.graphql(`
11678- mutation {
11679- minimizeComment(input: {classifier: OUTDATED, subjectId: "${testBuildComment.node_id}"}) {
11680- minimizedComment {
11681- minimizedReason
11682- }
11683- }
11684- }
11685- `);
11686- }
11687- await commentPR(REPO, destinationPRNumber, getTestBuildMessage(APP_PR_NUMBER, MOBILE_EXPENSIFY_PR_NUMBER));
11693+ await hidePreviousComment(REPO, destinationPRNumber, COMMENT_PREFIX);
11694+ await commentPR(REPO, destinationPRNumber, COMMENT_BODY || getTestBuildMessage(APP_PR_NUMBER, MOBILE_EXPENSIFY_PR_NUMBER));
1168811695}
1168911696if (require.main === require.cache[eval('__filename')]) {
1169011697 run();
@@ -12402,7 +12409,7 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
1240212409/******/ // startup
1240312410/******/ // Load entry module and return exports
1240412411/******/ // This entry module is referenced by other modules so it can't be inlined
12405- /******/ var __webpack_exports__ = __nccwpck_require__(3580 );
12412+ /******/ var __webpack_exports__ = __nccwpck_require__(7071 );
1240612413/******/ module.exports = __webpack_exports__;
1240712414/******/
1240812415/******/ })()
0 commit comments