| 174 | } |
| 175 | |
| 176 | async function commentOnPR(prNumber, packages) { |
| 177 | const packageList = packages |
| 178 | .map((p) => `- \`${p.name}@${p.version}\``) |
| 179 | .join(`\n`) |
| 180 | |
| 181 | const body = `This PR has been released! :rocket: |
| 182 | |
| 183 | The following packages include changes from this PR: |
| 184 | |
| 185 | ${packageList} |
| 186 | |
| 187 | Thanks for contributing to Electric!` |
| 188 | |
| 189 | try { |
| 190 | // Check if we already commented on this PR |
| 191 | const existingComments = execSync( |
| 192 | `gh api repos/${REPO}/issues/${prNumber}/comments --jq '[.[] | select(.body | contains("This PR has been released!"))] | length'`, |
| 193 | { encoding: `utf8`, stdio: [`pipe`, `pipe`, `pipe`] } |
| 194 | ).trim() |
| 195 | |
| 196 | if (parseInt(existingComments, 10) > 0) { |
| 197 | console.log(` Already commented on PR #${prNumber}, skipping`) |
| 198 | return |
| 199 | } |
| 200 | |
| 201 | // Use --body-file with stdin to avoid shell interpretation of backticks |
| 202 | execSync(`gh pr comment ${prNumber} --repo ${REPO} --body-file -`, { |
| 203 | input: body, |
| 204 | encoding: `utf8`, |
| 205 | stdio: [`pipe`, `inherit`, `inherit`], |
| 206 | }) |
| 207 | console.log(` Commented on PR #${prNumber}`) |
| 208 | } catch (e) { |
| 209 | console.error(` Failed to comment on PR #${prNumber}:`, e.message) |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | async function findLinkedIssues(prNumber) { |
| 214 | const [owner, repo] = REPO.split(`/`) |