Skip to content

Commit

Permalink
updated summary to have PRs title
Browse files Browse the repository at this point in the history
  • Loading branch information
Bullrich committed Jan 9, 2024
1 parent 7767e8b commit 16b3850
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/github/pullRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ export class PullRequestApi {
private readonly repo: { owner: string; repo: string },
) {}

async listPRs(onlyAutoMerge: boolean): Promise<number[]> {
async listPRs(
onlyAutoMerge: boolean,
): Promise<{ number: number; title: string }[]> {
const openPRs = await this.api.paginate(this.api.rest.pulls.list, {
...this.repo,
state: "open",
});

if (onlyAutoMerge) {
return openPRs.filter((pr) => pr.auto_merge).map((pr) => pr.number);
return openPRs
.filter((pr) => pr.auto_merge)
.map(({ number, title }) => ({ number, title }) as const);
} else {
return openPRs.map((pr) => pr.number);
return openPRs.map(({ number, title }) => ({ number, title }) as const);
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,20 @@ const action = async () => {
const rows: SummaryTableRow[] = [
[
{ data: "PR Number", header: true },
{ data: "Title", header: true },
{ data: "Result", header: true },
],
];
for (const number of prs) {
logger.info(`📡 - Updating #${number}`);
for (const { number, title } of prs) {
logger.info(`📡 - Updating ${title} #${number}`);
const repoTxt = `[#${number}](https://github.com/${repoInfo.owner}/${repoInfo.repo}/pull/${number})`;
try {
await api.update(number);
rows.push([repoTxt, "Pass ✅"]);
rows.push([repoTxt, title, "Pass ✅"]);
logger.info(`📥 - Updated #${number}`);
} catch (error) {
logger.error(error as string | Error);
rows.push([repoTxt, "Fail ❌"]);
rows.push([repoTxt, title, "Fail ❌"]);
}
}
logger.info(" - Finished updating PRs");
Expand Down

0 comments on commit 16b3850

Please sign in to comment.