(issue: number, latest: Tag)
| 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!`; |
| 157 | |
| 158 | debug(`Issue: https://github.com/${GITHUB_REPOSITORY}/issues/${issue}`); |
| 159 | |
| 160 | let shouldClose = true; |
| 161 | if (ISSUE_LABELS_TO_KEEP_OPEN) { |
| 162 | try { |
| 163 | let labels = getIssueLabels(String(issue)); |
| 164 | console.log("Labels on issue #" + issue + ": " + labels.join(", ")); |
| 165 | shouldClose = !labels.includes(ISSUE_LABELS_TO_KEEP_OPEN); |
| 166 | } catch (err) { |
| 167 | debug(`⚠️ Unable to get labels for issue #${issue}: ${String(err)}`); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | if (DRY_RUN) { |
| 172 | debug(`[dry-run] would comment on issue #${issue}`); |
| 173 | if (shouldClose) { |
| 174 | debug(`[dry-run] would close issue #${issue}`); |
| 175 | } |
| 176 | debug( |
| 177 | `[dry-run] would remove label "${ISSUE_LABELS_TO_REMOVE}" from issue #${issue}`, |
| 178 | ); |
| 179 | } else { |
| 180 | // Comment on linked issue |
| 181 | logAndExec([ |
| 182 | "gh", |
| 183 | "issue", |
| 184 | "comment", |
| 185 | String(issue), |
| 186 | "--body", |
| 187 | issueComment, |
| 188 | ]); |
| 189 | |
| 190 | // Close linked issue |
| 191 | if (shouldClose) { |
| 192 | logAndExec(["gh", "issue", "close", String(issue)]); |
| 193 | } else { |
| 194 | debug( |
| 195 | `Skipping close of issue #${issue} due to "${ISSUE_LABELS_TO_KEEP_OPEN}" label`, |
| 196 | ); |
| 197 | } |
| 198 | |
| 199 | // Remove labels from linked issue |
| 200 | logAndExec([ |
| 201 | "gh", |
| 202 | "issue", |
| 203 | "edit", |
| 204 | String(issue), |
| 205 | "--remove-label", |
| 206 | ISSUE_LABELS_TO_REMOVE, |
| 207 | ]); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | type MergedPR = { |
| 212 | number: number; |
no test coverage detected
searching dependent graphs…