(pr: MergedPR, latest: Tag)
| 120 | } |
| 121 | |
| 122 | async function commentOnPrAndLinkedIssues(pr: MergedPR, latest: Tag) { |
| 123 | let prComment = `🤖 Hello there,\n\nWe recently published version \`${latest.clean}\` which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!\n\nThanks!`; |
| 124 | |
| 125 | debug(`\nPR: https://github.com/${GITHUB_REPOSITORY}/pull/${pr.number}`); |
| 126 | |
| 127 | if (DRY_RUN) { |
| 128 | debug(`[dry-run] would comment on PR #${pr.number}`); |
| 129 | } else { |
| 130 | // Comment on PR |
| 131 | logAndExec(["gh", "pr", "comment", String(pr.number), "--body", prComment]); |
| 132 | |
| 133 | // Remove PR labels |
| 134 | logAndExec([ |
| 135 | "gh", |
| 136 | "pr", |
| 137 | "edit", |
| 138 | String(pr.number), |
| 139 | "--remove-label", |
| 140 | PR_LABELS_TO_REMOVE, |
| 141 | ]); |
| 142 | } |
| 143 | |
| 144 | let promises = pr.issues.map((issue) => commentOnIssue(issue, latest)); |
| 145 | |
| 146 | let results = await Promise.allSettled(promises); |
| 147 | let failures = results.filter((result) => result.status === "rejected"); |
| 148 | if (failures.length > 0) { |
| 149 | throw new Error( |
| 150 | `the following commands failed: ${JSON.stringify(failures)}`, |
| 151 | ); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | async function commentOnIssue(issue: number, latest: Tag) { |
| 156 | let issueComment = `🤖 Hello there,\n\nWe recently published version \`${latest.clean}\` which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!\n\nThanks!`; |
no test coverage detected